|
|
@ -10,7 +10,7 @@ |
|
|
|
ARG SERVICE |
|
|
|
|
|
|
|
# The base image to use |
|
|
|
ARG BASE=base-alpine |
|
|
|
ARG BASE=alpine |
|
|
|
|
|
|
|
# Base Definitions --------------------------------------------------------------------------------- |
|
|
|
|
|
|
@ -38,7 +38,7 @@ FROM base-slim AS base-slim-dev |
|
|
|
# Development Image -------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
# Define the base image |
|
|
|
FROM ${BASE}-dev AS dev |
|
|
|
FROM base-${BASE}-dev AS dev |
|
|
|
ARG SERVICE |
|
|
|
WORKDIR /opt/app |
|
|
|
|
|
|
@ -60,12 +60,13 @@ CMD [ "yarn", "run", "start:dev" ] |
|
|
|
# Build Definitions -------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
# Create the builder image with all dependencies |
|
|
|
FROM ${BASE}-dev AS builder-base |
|
|
|
FROM base-${BASE}-dev AS builder-base |
|
|
|
WORKDIR /app |
|
|
|
RUN yarn global add lerna typescript rimraf |
|
|
|
COPY docker/scripts docker/scripts |
|
|
|
COPY lerna.json package.json tsconfig.json ./ |
|
|
|
COPY lerna.json package.json tsconfig*.json ./ |
|
|
|
RUN yarn install |
|
|
|
COPY api api |
|
|
|
COPY packages packages |
|
|
|
|
|
|
|
# Copy service package.json and patch files if they exist |
|
|
@ -76,18 +77,20 @@ COPY services/${SERVICE}/patches* ./services/${SERVICE}/patches |
|
|
|
|
|
|
|
# Cache an image containing only the prod-dependencies |
|
|
|
FROM builder AS prod-deps |
|
|
|
ARG BASE |
|
|
|
RUN lerna bootstrap -- --production --no-optional |
|
|
|
RUN yarn run export:deps |
|
|
|
RUN yarn run export:deps ${BASE} |
|
|
|
|
|
|
|
# Build the service |
|
|
|
FROM builder AS build |
|
|
|
ARG BASE |
|
|
|
ARG SERVICE |
|
|
|
COPY services/${SERVICE} ./services/${SERVICE} |
|
|
|
RUN lerna clean --yes && lerna bootstrap && lerna run clean && lerna run build |
|
|
|
RUN yarn run export:builds |
|
|
|
RUN yarn run export:builds ${BASE} |
|
|
|
|
|
|
|
# Return to base image with the compiled files and production dependencies |
|
|
|
FROM ${BASE} AS prod |
|
|
|
FROM base-${BASE} AS prod |
|
|
|
ARG SERVICE |
|
|
|
WORKDIR /app |
|
|
|
COPY --from=prod-deps /app/build /opt |
|
|
|