Update Dockerfile
This commit is contained in:
parent
6ed6682824
commit
bd5d50cf97
@ -4,13 +4,14 @@ FROM node:19-alpine AS deps
|
|||||||
WORKDIR leCoffre-front
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
|
COPY .env ./
|
||||||
|
|
||||||
RUN apk update && apk add openssh-client git
|
RUN apk update && apk add openssh-client git
|
||||||
|
|
||||||
COPY id_rsa /root/.ssh/id_rsa
|
COPY id_rsa /root/.ssh/id_rsa
|
||||||
RUN chmod 600 ~/.ssh/id_rsa
|
RUN chmod 600 ~/.ssh/id_rsa
|
||||||
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
||||||
RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
RUN ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts
|
||||||
|
|
||||||
RUN npm install --frozen-lockfile
|
RUN npm install --frozen-lockfile
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ WORKDIR leCoffre-front
|
|||||||
|
|
||||||
COPY --from=deps leCoffre-front/node_modules ./node_modules
|
COPY --from=deps leCoffre-front/node_modules ./node_modules
|
||||||
COPY --from=deps leCoffre-front/package.json package.json
|
COPY --from=deps leCoffre-front/package.json package.json
|
||||||
|
COPY --from=deps leCoffre-front/.env ./.env
|
||||||
COPY tsconfig.json tsconfig.json
|
COPY tsconfig.json tsconfig.json
|
||||||
COPY next.config.js next.config.js
|
COPY next.config.js next.config.js
|
||||||
COPY src src
|
COPY src src
|
||||||
@ -39,6 +41,7 @@ COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modu
|
|||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next
|
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/next.config.js ./next.config.js
|
||||||
COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/.env ./.env
|
||||||
|
|
||||||
USER lecoffreuser
|
USER lecoffreuser
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
# Install dependencies only when needed
|
|
||||||
FROM node:19-alpine AS deps
|
|
||||||
|
|
||||||
WORKDIR leCoffre-front
|
|
||||||
|
|
||||||
COPY package.json ./
|
|
||||||
|
|
||||||
RUN apk update && apk add openssh-client git
|
|
||||||
|
|
||||||
COPY id_rsa /root/.ssh/id_rsa
|
|
||||||
RUN chmod 600 ~/.ssh/id_rsa
|
|
||||||
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
|
||||||
RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
|
||||||
|
|
||||||
RUN npm install --frozen-lockfile
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
|
||||||
FROM node:19-alpine AS builder
|
|
||||||
|
|
||||||
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 src src
|
|
||||||
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
|
||||||
FROM node:19-alpine AS production
|
|
||||||
|
|
||||||
WORKDIR leCoffre-front
|
|
||||||
|
|
||||||
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/package.json ./package.json
|
|
||||||
|
|
||||||
USER lecoffreuser
|
|
||||||
|
|
||||||
CMD ["npm", "run", "start"]
|
|
||||||
EXPOSE 3000
|
|
Loading…
x
Reference in New Issue
Block a user