feat: initial docker build files
This commit is contained in:
parent
13bc88a4fe
commit
79852df5df
3 changed files with 59 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
.astro/
|
.astro/
|
||||||
|
.output/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
*~
|
*~
|
||||||
|
|
51
Dockerfile
Normal file
51
Dockerfile
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
FROM docker.io/library/node:lts-alpine AS base
|
||||||
|
|
||||||
|
# Prepare work directory
|
||||||
|
WORKDIR /cozy
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
|
||||||
|
# Prepare pnpm https://pnpm.io/installation#using-corepack
|
||||||
|
# workaround for npm registry key change
|
||||||
|
# ref. `pnpm@10.1.0` / `pnpm@9.15.4` cannot be installed due to key id mismatch · Issue #612 · nodejs/corepack
|
||||||
|
# - https://github.com/nodejs/corepack/issues/612#issuecomment-2629496091
|
||||||
|
RUN npm i -g corepack@latest && corepack enable
|
||||||
|
|
||||||
|
# Prepare deps
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add git --no-cache
|
||||||
|
|
||||||
|
# Copy all source files
|
||||||
|
COPY package.json ./
|
||||||
|
COPY pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# Run full install
|
||||||
|
RUN pnpm i --frozen-lockfile --ignore-scripts
|
||||||
|
|
||||||
|
# Copy source
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# Build
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
|
||||||
|
ARG UID=911
|
||||||
|
ARG GID=911
|
||||||
|
|
||||||
|
# Create a dedicated user and group
|
||||||
|
RUN set -eux; \
|
||||||
|
addgroup -g $GID cozy; \
|
||||||
|
adduser -u $UID -D -G cozy cozy;
|
||||||
|
|
||||||
|
USER cozy
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
COPY --from=builder /cozy/ ./
|
||||||
|
|
||||||
|
EXPOSE 4321/tcp
|
||||||
|
|
||||||
|
ENV PORT=4321
|
||||||
|
|
||||||
|
CMD ["node", "server.mjs"]
|
7
docker-compose.yaml
Normal file
7
docker-compose.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
services:
|
||||||
|
cozy:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- 4321:4321
|
Loading…
Reference in a new issue