CorentinTh_enclosed/Dockerfile.rootless
Corentin THOMASSET 9f7797afce
feat(docker): armv7 support (#316)
* refactor(docker): use node-slim image for build stage

* feat(docker): armv7 support
2024-11-05 12:30:27 +00:00

49 lines
1.5 KiB
Docker

# Base image is node:22-slim, we cannot use node:22-alpine because of
# a known issue for arm/v7 architecture (hangs on dependency installation)
# see https://github.com/nodejs/docker-node/issues/2077
FROM node:22-slim AS builder
# Set the working directory for the app
WORKDIR /app
# Copy package.json and pnpm-lock.yaml to install dependencies
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
COPY packages/crypto/package.json packages/crypto/package.json
COPY packages/lib/package.json packages/lib/package.json
COPY packages/app-client/package.json packages/app-client/package.json
COPY packages/app-server/package.json packages/app-server/package.json
# Install pnpm
RUN npm install -g pnpm --ignore-scripts && pnpm install --frozen-lockfile --ignore-scripts
# Copy the entire app
COPY . .
# Build the apps
RUN pnpm --filter @enclosed/crypto run build && \
pnpm --filter @enclosed/lib run build && \
pnpm --filter @enclosed/app-client run build && \
pnpm --filter @enclosed/app-server run build:node
# Production image
FROM node:22-alpine
# Create a non-root user and group
RUN addgroup -S nonroot && adduser -S nonroot -G nonroot
WORKDIR /app
# Copy the built apps
COPY --from=builder /app/packages/app-client/dist ./public
COPY --from=builder /app/packages/app-server/dist-node/index.cjs ./index.cjs
# Create the .data directory and set permissions
RUN mkdir -p /app/.data && chown -R nonroot:nonroot /app
# Change the user to nonroot
USER nonroot
EXPOSE 8787
CMD ["node", "index.cjs"]