⚡ Optimize docker-setup
All checks were successful
Deploy website / build-and-deploy (push) Successful in 9m29s
All checks were successful
Deploy website / build-and-deploy (push) Successful in 9m29s
Signed-off-by: SindreKjelsrud <sindre@kjelsrud.dev>
This commit is contained in:
parent
c49809833d
commit
8f7a5861ff
2 changed files with 18 additions and 10 deletions
27
Dockerfile
27
Dockerfile
|
@ -1,18 +1,25 @@
|
|||
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 . /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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
services:
|
||||
web:
|
||||
container_name: kjelsrud.dev
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
|
|
Loading…
Add table
Reference in a new issue