54 lines
No EOL
1.4 KiB
Docker
54 lines
No EOL
1.4 KiB
Docker
# okay, let's figure this out
|
|
|
|
FROM node:23.11-slim AS base
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
WORKDIR /app
|
|
|
|
# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code.
|
|
# Therefore, the `-deps` steps will be skipped if only the source code changes.
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
FROM base AS prod-deps
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
|
|
|
|
FROM base AS build-deps
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
|
|
|
FROM build-deps AS build
|
|
COPY . .
|
|
RUN pnpm run build
|
|
|
|
FROM base AS runtime
|
|
# Copy dependencies
|
|
COPY --from=prod-deps /app/node_modules ./node_modules
|
|
# Copy the built output
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
# Bind to all interfaces
|
|
ENV HOST=0.0.0.0
|
|
# Port to listen on
|
|
ENV PORT=4321
|
|
# Just convention, not required
|
|
EXPOSE 4321
|
|
|
|
# Start the app
|
|
CMD ["node", "./dist/server/entry.mjs"]
|
|
|
|
# Install NGINX
|
|
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy NGINX config
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Serve static files from /app/dist/client
|
|
RUN mkdir -p /var/www/html && ln -s /app/dist/client /var/www/html
|
|
|
|
# Expose NGINX port
|
|
EXPOSE 8080
|
|
|
|
# Start both NGINX and Node server
|
|
CMD service nginx start && node ./dist/server/entry.mjs |