Browse Source

Update Dockerfiles and build scripts to fix production build errors.

dev
David Ludwig 4 years ago
parent
commit
93b4e6c90a
4 changed files with 15 additions and 11 deletions
  1. +10
    -7
      Dockerfile
  2. +1
    -1
      docker-compose.dev.yml
  3. +3
    -3
      docker-compose.yml
  4. +1
    -0
      package.json

+ 10
- 7
Dockerfile View File

@ -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


+ 1
- 1
docker-compose.dev.yml View File

@ -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:


+ 3
- 3
docker-compose.yml View File

@ -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"


+ 1
- 0
package.json View File

@ -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",


Loading…
Cancel
Save