55 lines
1.8 KiB
Docker
55 lines
1.8 KiB
Docker
# Install dependencies only when needed
|
|
FROM node:19-alpine AS deps
|
|
|
|
WORKDIR leCoffre
|
|
|
|
RUN npm install -D prisma@4.11.0
|
|
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
|
|
|
|
# Install Google Chrome Stable and fonts
|
|
# Note: this installs the necessary libs to make the browser work with Puppeteer.
|
|
RUN apt-get update && apt-get install gnupg wget -y && \
|
|
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
|
|
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
|
|
apt-get update && \
|
|
apt-get install google-chrome-stable -y --no-install-recommends && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN npm install --frozen-lockfile
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM node:19-alpine AS builder
|
|
|
|
WORKDIR leCoffre
|
|
|
|
COPY --from=deps leCoffre/node_modules ./node_modules
|
|
COPY --from=deps leCoffre/package.json package.json
|
|
COPY tsconfig.json tsconfig.json
|
|
COPY src src
|
|
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM node:19-alpine AS production
|
|
|
|
WORKDIR leCoffre
|
|
|
|
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
|
|
|
COPY --from=builder --chown=lecoffreuser leCoffre/node_modules ./node_modules
|
|
COPY --from=builder --chown=lecoffreuser leCoffre/dist dist
|
|
COPY --from=builder --chown=lecoffreuser leCoffre/package.json ./package.json
|
|
COPY --from=builder --chown=lecoffreuser leCoffre/src/common/databases ./src/common/databases
|
|
|
|
USER lecoffreuser
|
|
|
|
CMD ["npm", "run", "start"]
|
|
EXPOSE 3001 |