Simplifying Docker configuration

This commit is contained in:
spaghet committed 2025-11-16 20:08:48 -05:00
1 parent b847794e48
commit 186fa89f60
2 files changed
+14 -23

No files matched your search

+10 -21
View File
@@ -1,29 +1,18 @@
FROM node:22-alpine AS base FROM node:lts-alpine AS builder
WORKDIR /app 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. COPY package*.json ./
# Therefore, the `-deps` steps will be skipped if only the source code changes. RUN npm ci
COPY package.json package-lock.json ./
FROM base AS prod-deps
RUN npm install --omit=dev
FROM base AS build-deps
RUN npm install
FROM build-deps AS build
COPY . . COPY . .
RUN npm run build RUN npm run build
FROM base AS runtime # Stage 2: Serve the static files with a lightweight web server
COPY --from=prod-deps /app/node_modules ./node_modules # Copy dependencies FROM nginx:alpine
COPY --from=build /app/dist ./dist # Copy the built output
# Bind to all interfaces COPY --from=builder /app/dist /usr/share/nginx/html
ENV HOST=0.0.0.0
# Port to listen on
ENV PORT=4321
# Just convention, not required
EXPOSE 4321
CMD node ./dist/server/entry.mjs # Start the app EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
+4 -2
View File
@@ -1,9 +1,11 @@
services: services:
astro-app: spaghet-home:
container_name: spaghet-home
network_mode: bridge
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "4321:4321" - "4321:80"
volumes: volumes:
- .:/app - .:/app