Optimize docker-setup
Some checks failed
Deploy website / build-and-deploy (push) Failing after 1m38s

Signed-off-by: SindreKjelsrud <sindre@kjelsrud.dev>
This commit is contained in:
Sid 2025-06-01 15:51:38 +02:00
parent c49809833d
commit 70c765953b
Signed by: sidski
GPG key ID: D2BBDF3EDE6BA9A6
2 changed files with 19 additions and 10 deletions

View file

@ -1,18 +1,26 @@
FROM node:lts-alpine AS build
FROM node:lts-alpine AS base
WORKDIR /app
RUN npm install -g pnpm
# 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 ./
COPY project.inlang ./project.inlang
COPY . /app
FROM base AS prod-deps
RUN echo y | npm exec -- pnpm install --prod
RUN pnpm install
RUN pnpm run build
FROM base AS build-deps
RUN npm exec -- pnpm install
FROM caddy:alpine
FROM build-deps AS build
COPY . .
RUN npm exec -- pnpm run build
COPY --from=build /app/dist /usr/share/caddy
FROM base AS runtime
COPY --from=prod-deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
ENV HOST=0.0.0.0
ENV PORT=4321
EXPOSE 4321
CMD ["caddy", "file-server", "--root", "/usr/share/caddy", "--listen", ":4321"]
ENTRYPOINT node ./dist/server/entry.mjs

View file

@ -1,5 +1,6 @@
services:
web:
container_name: kjelsrud.dev
restart: always
build:
context: .