Update Dockerfile
This commit is contained in:
parent
028d72025a
commit
d5eb1e968b
49
Dockerfile
49
Dockerfile
@ -1,46 +1,29 @@
|
|||||||
# Install dependencies only when needed
|
# syntax=docker/dockerfile:1.4
|
||||||
FROM node:19-alpine AS deps
|
FROM node:19-alpine AS deps
|
||||||
|
WORKDIR /leCoffre-front
|
||||||
WORKDIR leCoffre-front
|
|
||||||
|
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
|
|
||||||
RUN apk update && apk add openssh-client git
|
RUN apk update && apk add --no-cache openssh-client git
|
||||||
|
|
||||||
COPY id_rsa /root/.ssh/id_rsa
|
# Forward SSH agent via BuildKit (clé jamais écrite dans l'image)
|
||||||
RUN chmod 600 ~/.ssh/id_rsa
|
RUN --mount=type=ssh \
|
||||||
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
mkdir -p /root/.ssh && \
|
||||||
RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts && \
|
||||||
|
npm install --frozen-lockfile
|
||||||
|
|
||||||
RUN npm install --frozen-lockfile
|
# Configuration pour le développement
|
||||||
|
FROM node:19-alpine AS development
|
||||||
|
WORKDIR /leCoffre-front
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
COPY --from=deps /leCoffre-front/node_modules ./node_modules
|
||||||
FROM node:19-alpine AS builder
|
COPY --from=deps /leCoffre-front/package.json ./package.json
|
||||||
|
COPY . .
|
||||||
WORKDIR leCoffre-front
|
|
||||||
|
|
||||||
COPY --from=deps leCoffre-front/node_modules ./node_modules
|
|
||||||
COPY --from=deps leCoffre-front/package.json package.json
|
|
||||||
COPY tsconfig.json tsconfig.json
|
|
||||||
COPY next.config.js next.config.js
|
|
||||||
COPY src src
|
|
||||||
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
|
||||||
FROM node:19-alpine AS production
|
|
||||||
|
|
||||||
WORKDIR leCoffre-front
|
|
||||||
|
|
||||||
|
# Création de l'utilisateur non-root
|
||||||
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
||||||
|
|
||||||
COPY public ./public
|
|
||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modules
|
|
||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next
|
|
||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/next.config.js ./next.config.js
|
|
||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json
|
|
||||||
|
|
||||||
USER lecoffreuser
|
USER lecoffreuser
|
||||||
|
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["npm", "run", "dev"]
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
Loading…
x
Reference in New Issue
Block a user