mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 02:53:51 +00:00
begin work on deployment process
This commit is contained in:
@@ -1,32 +1,41 @@
|
||||
from node:22-alpine
|
||||
# Stage 1: Build and install dependencies
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install necessary dependencies, including pnpm
|
||||
RUN set -eux \
|
||||
& apk add \
|
||||
--no-cache \
|
||||
nodejs \
|
||||
curl
|
||||
&& apk add --no-cache nodejs curl \
|
||||
&& npm install -g pnpm
|
||||
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Set build arguments
|
||||
ARG CONTAINER_WEB_VERSION
|
||||
ARG ENVIRONMENT
|
||||
ARG BUILD_DATE
|
||||
ARG GIT_COMMIT
|
||||
|
||||
RUN echo "PUBLIC_VERSION=${CONTAINER_FHCC_VERSION}" > /app/.env && \
|
||||
# Create .env file with build-time environment variables
|
||||
RUN echo "PUBLIC_VERSION=${CONTAINER_WEB_VERSION}" > /app/.env && \
|
||||
echo "PUBLIC_ENVIRONMENT=${ENVIRONMENT}" >> /app/.env && \
|
||||
echo "PUBLIC_BUILD_DATE=${BUILD_DATE}" >> /app/.env && \
|
||||
echo "PUBLIC_GIT_COMMIT=${GIT_COMMIT}" >> /app/.env
|
||||
|
||||
RUN pnpm install --frozen-lockfile --production
|
||||
RUN pnpm run build
|
||||
# Install dependencies (including development dependencies) and build the project
|
||||
RUN pnpm install --frozen-lockfile && pnpm run build
|
||||
|
||||
# Stage 2: Set up the production environment
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Expose the port for the application
|
||||
EXPOSE 3000
|
||||
|
||||
CMD node ./dist/server/entry.mjs
|
||||
COPY --from=builder /app/.dist ./
|
||||
# Copy the build artifacts from the builder stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Set the command to run the application
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user