Skip to content

Commit

Permalink
build: use base Docker images
Browse files Browse the repository at this point in the history
Hopefully building containers will be a bit faster now.

Related to #83
  • Loading branch information
JoosepAlviste committed Feb 8, 2024
1 parent e09ea52 commit d9438cd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 38 deletions.
14 changes: 2 additions & 12 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
FROM node:20-alpine AS base

RUN npm i -g pnpm@8


FROM base AS dependencies
FROM ghcr.io/joosepalviste/serieslist-dependencies:latest AS dependencies

WORKDIR /app

# Install dependencies for compiling node-gyp (since there is no pre-built
# binary for Alpine)
# https://stackoverflow.com/a/59538284/7044732
RUN apk add g++ make python3

COPY . .

RUN pnpm -F api --prod deploy pruned
Expand All @@ -25,7 +15,7 @@ RUN rm -rf node_modules && rm -rf pruned && pnpm install
RUN pnpm exec nx build @serieslist/api


FROM base AS production
FROM ghcr.io/joosepalviste/serieslist-base:latest AS production

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"scripts": {
"build": "rimraf dist && NODE_ENV=production tsx bin/build.ts",
"build:docker": "(cd ../.. && docker buildx build --push --cache-to type=gha,mode=max,scope=webapp --cache-from type=gha,scope=webapp -t ghcr.io/joosepalviste/serieslist-api:latest -f apps/api/Dockerfile --target production .)",
"build:docker": "(cd ../.. && docker buildx build --push --cache-to type=gha,mode=max,scope=api --cache-from type=gha,scope=api -t ghcr.io/joosepalviste/serieslist-api:latest -f apps/api/Dockerfile --target production .)",
"build:e2e": "(cd ../.. && nx run @serieslist/api:build)",
"clear-test-db": "dotenv -e ../../.env.test tsx bin/clearDatabase.ts",
"codegen": "DOTENV_CONFIG_PATH='../../.env' graphql-codegen-esm -r dotenv/config",
Expand Down
14 changes: 2 additions & 12 deletions apps/jobs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
FROM node:20-alpine AS base

RUN npm i -g pnpm@8


FROM base AS dependencies
FROM ghcr.io/joosepalviste/serieslist-dependencies:latest AS dependencies

WORKDIR /app

# Install dependencies for compiling node-gyp (since there is no pre-built
# binary for Alpine)
# https://stackoverflow.com/a/59538284/7044732
RUN apk add g++ make python3

COPY . .

RUN pnpm -F api --prod deploy pruned
Expand All @@ -25,7 +15,7 @@ RUN rm -rf node_modules && rm -rf pruned && pnpm install
RUN pnpm exec nx build @serieslist/api


FROM base AS production
FROM ghcr.io/joosepalviste/serieslist-base:latest AS production

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion apps/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"scripts": {
"build": "rimraf dist && NODE_ENV=production tsx bin/build.ts",
"build:docker": "(cd ../.. && docker buildx build --push --cache-to type=gha,mode=max,scope=webapp --cache-from type=gha,scope=webapp -t ghcr.io/joosepalviste/serieslist-jobs:latest -f apps/api/Dockerfile --target production .)",
"build:docker": "(cd ../.. && docker buildx build --push --cache-to type=gha,mode=max,scope=jobs --cache-from type=gha,scope=jobs -t ghcr.io/joosepalviste/serieslist-jobs:latest -f apps/api/Dockerfile --target production .)",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"start": "NODE_ENV=development tsx watch --clear-screen=false src/main.ts",
Expand Down
14 changes: 2 additions & 12 deletions apps/webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
FROM node:20-alpine AS base

RUN npm i -g pnpm@8


FROM base AS dependencies
FROM ghcr.io/joosepalviste/serieslist-dependencies:latest AS dependencies

WORKDIR /app

# Install dependencies for compiling node-gyp (since there is no pre-built
# binary for Alpine)
# https://stackoverflow.com/a/59538284/7044732
RUN apk add g++ make python3

COPY . .

RUN pnpm -F webapp --prod deploy pruned
Expand All @@ -38,7 +28,7 @@ RUN pnpm -F webapp deploy pruned
RUN cd pruned && pnpm build


FROM base AS production
FROM ghcr.io/joosepalviste/serieslist-base:latest AS production

WORKDIR /app

Expand Down

0 comments on commit d9438cd

Please sign in to comment.