diff --git a/Dockerfile b/Dockerfile index f9e32313..4b085ebc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,14 @@ -FROM docker.io/node:alpine as builder +FROM --platform=${BUILDPLATFORM} docker.io/library/node:16.13-alpine3.15 as builder RUN apk add --no-cache git python3 build-base -COPY . /app WORKDIR /app -RUN yarn install \ - && yarn build -FROM docker.io/nginx:alpine +# Install the dependencies first +COPY yarn.lock package.json ./ +RUN yarn install + +# Copy the rest and build the app +COPY . . +RUN yarn build + +FROM --platform=${TARGETPLATFORM} docker.io/library/nginx:alpine COPY --from=builder /app/target /usr/share/nginx/html diff --git a/doc/docker.md b/doc/docker.md index 910938f0..6ca67c02 100644 --- a/doc/docker.md +++ b/doc/docker.md @@ -35,7 +35,9 @@ To stop the container, simply hit `ctrl+c`. In this repository, create a Docker image: -``` +```sh +# Enable BuildKit https://docs.docker.com/develop/develop-images/build_enhancements/ +export DOCKER_BUILDKIT=1 docker build -t hydrogen . ```