From 93b4e6c90a5c4ac2feff133f775fb040272e07ae Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Thu, 6 May 2021 03:40:01 -0500 Subject: [PATCH] Update Dockerfiles and build scripts to fix production build errors. --- Dockerfile | 17 ++++++++++------- docker-compose.dev.yml | 2 +- docker-compose.yml | 6 +++--- package.json | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 508522f..92a6253 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index ef6a66f..b6036c5 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -9,7 +9,7 @@ services: volumes: - ./api:/opt/app/api - ./packages:/opt/app/packages - - ./services/autoplex-webui:/opt/app/services/autoplex-webui + - ./services/webui:/opt/app/services/webui tty: true request: diff --git a/docker-compose.yml b/docker-compose.yml index f21929b..d93285c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,9 @@ services: build: context: . args: - SERVICE: autoplex-webui + SERVICE: webui env_file: - ./services/autoplex-webui/.env + ./services/webui/.env restart: unless-stopped request: @@ -99,7 +99,7 @@ services: build: context: . args: - BASE: base-slim + BASE: slim SERVICE: torrent depends_on: - "database" diff --git a/package.json b/package.json index f0aefff..f7f8678 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "scripts": { "build": "lerna run build", + "build:api": "lerna run build --scope=@autoplex-api/*", "build:packages": "lerna run build --scope=@autoplex/*", "build:services": "lerna run build --scope=@autoplex-service/*", "export": "rimraf ./build && yarn run export:deps && yarn run export:builds",