Skip to content

Instantly share code, notes, and snippets.

@Israphel
Created December 7, 2022 15:03
Show Gist options
  • Save Israphel/6041571d03059867e8c698d37700f5d4 to your computer and use it in GitHub Desktop.
Save Israphel/6041571d03059867e8c698d37700f5d4 to your computer and use it in GitHub Desktop.
# Base
FROM node:16.16.0-alpine3.16 AS base
WORKDIR /opt/app
RUN apk update && \
apk add --no-cache jq
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json
RUN npm install --global npm@$(cat package.json | jq .engines.npm | sed 's/"//g')
RUN npm --version
RUN apk delete jq
# Builder
FROM base AS build
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PASSWORD
WORKDIR /opt/app
RUN apk update && \
apk add --no-cache curl alpine-sdk
RUN echo "registry=https://splitio.jfrog.io/artifactory/api/npm/npm-all-virtual/" >> ~/.npmrc
RUN curl -s -u${ARTIFACTORY_USER}:${ARTIFACTORY_PASSWORD} https://splitio.jfrog.io/artifactory/api/npm/auth >> ~/.npmrc
# Babel stage
FROM build AS babel
COPY .babelrc ./.babelrc
COPY src/pages ./src/pages
RUN npm ci
RUN npm run build
# Build stage
FROM build AS builder
RUN npm ci -- production
# Runner stage
FROM base AS runner
COPY --from=builder /opt/app/node_modules ./node_modules
COPY --from=babel /opt/app/build ./build
COPY build/webconsole-bff-hash.txt ./webconsole-bff-hash.txt
COPY src ./src
EXPOSE 3004
ENTRYPOINT ["node", "./node_modules/nodejs-microservice-toolkit/startServer.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment