Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Define base image for multi-stage Docker build #4743

Merged
merged 2 commits into from May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/blog/turbo-0-4-0.mdx
Expand Up @@ -102,7 +102,7 @@ COPY --from=pruner /app/out/yarn.lock ./yarn.lock
RUN yarn install

# Copy source code of pruned subworkspace and build
FROM base as builder
FROM base AS builder
WORKDIR /app
COPY --from=pruner /app/.git ./.git
COPY --from=pruner /app/out/full/ .
Expand Down
8 changes: 5 additions & 3 deletions docs/pages/repo/docs/handbook/deploying-with-docker.mdx
Expand Up @@ -114,7 +114,9 @@ Splitting up **dependencies** and **source files** in this way lets us **only ru
Our detailed [`with-docker` example](https://github.com/vercel/turbo/tree/main/examples/with-docker) goes into depth on how to utilise `prune` to its full potential. Here's the Dockerfile, copied over for convenience.

```docker
FROM node:alpine AS builder
FROM node:18-alpine AS base

FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
Expand All @@ -124,7 +126,7 @@ COPY . .
RUN turbo prune --scope=web --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
Expand All @@ -139,7 +141,7 @@ RUN yarn install
COPY --from=builder /app/out/full/ .
RUN yarn turbo run build --filter=web...

FROM node:alpine AS runner
FROM base AS runner
WORKDIR /app

# Don't run production as root
Expand Down
8 changes: 5 additions & 3 deletions examples/with-docker/apps/api/Dockerfile
@@ -1,7 +1,9 @@
FROM node:18-alpine AS base

# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.

FROM node:alpine AS builder
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
Expand All @@ -12,7 +14,7 @@ COPY . .
RUN turbo prune --scope=api --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
Expand All @@ -36,7 +38,7 @@ COPY turbo.json turbo.json

RUN yarn turbo run build --filter=api...

FROM node:alpine AS runner
FROM base AS runner
WORKDIR /app

# Don't run production as root
Expand Down
8 changes: 5 additions & 3 deletions examples/with-docker/apps/web/Dockerfile
@@ -1,7 +1,9 @@
FROM node:18-alpine AS base

# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!

FROM node:alpine AS builder
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
Expand All @@ -12,7 +14,7 @@ COPY . .
RUN turbo prune --scope=web --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
Expand All @@ -36,7 +38,7 @@ COPY turbo.json turbo.json

RUN yarn turbo run build --filter=web...

FROM node:alpine AS runner
FROM base AS runner
WORKDIR /app

# Don't run production as root
Expand Down