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

Multiarch build #18

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,42 @@ jobs:
- image: circleci/node:lts
steps:
- checkout
- setup_remote_docker
- setup_remote_docker:
version: 20.10.14
- run:
name: Install Docker buildx tool
command: |
mkdir -vp ~/.docker/cli-plugins/
wget -O ~/.docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/v0.7.0/buildx-v0.7.0.linux-amd64"
chmod a+x ~/.docker/cli-plugins/docker-buildx
cat /etc/os-release
docker version
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- run:
name: Set $DOCKER_TAG
command: echo 'export DOCKER_TAG=${CIRCLE_TAG:-$CIRCLE_BRANCH}' >> $BASH_ENV
command: |
echo 'export DOCKER_TAG=${CIRCLE_TAG:-$CIRCLE_BRANCH}' >> $BASH_ENV
echo 'export DOCKER_CLI_EXPERIMENTAL=enabled' >> $BASH_ENV
- run:
name: Create buildx
command: |
docker context create buildx-build
docker buildx create --use buildx-build
docker run --privileged --rm tonistiigi/binfmt --install all
- run:
name: Build docker images
command: |
docker build -f docker/Dockerfile -t staticdeploy/app-server:$DOCKER_TAG .
docker buildx build --platform=linux/arm64/v8 --build-arg BUILDPLATFORM=linux/arm64/v8 --push -f docker/Dockerfile -t staticdeploy/app-server:$DOCKER_TAG-arm64 .
docker buildx build --platform=linux/amd64 --build-arg BUILDPLATFORM=linux/amd64 --push -f docker/Dockerfile -t staticdeploy/app-server:$DOCKER_TAG-amd64 .
docker build -f docker/Dockerfile.cra-builder -t staticdeploy/app-server:$DOCKER_TAG-cra-builder .
docker build -f docker/Dockerfile.cra-runtime -t staticdeploy/app-server:$DOCKER_TAG-cra-runtime --build-arg DOCKER_TAG=$DOCKER_TAG .
- run:
name: Push docker images
command: |
docker push staticdeploy/app-server:$DOCKER_TAG
docker manifest create staticdeploy/app-server:$DOCKER_TAG --amend staticdeploy/app-server:$DOCKER_TAG-arm64 --amend staticdeploy/app-server:$DOCKER_TAG-amd64
docker manifest push staticdeploy/app-server:$DOCKER_TAG
docker push staticdeploy/app-server:$DOCKER_TAG-cra-builder
docker push staticdeploy/app-server:$DOCKER_TAG-cra-runtime
npm-publish:
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:lts-alpine
ARG BUILDPLATFORM
FROM --platform=${BUILDPLATFORM} node:lts-slim

# Install app-server into directory /app-server
WORKDIR /app-server
Expand All @@ -11,7 +12,7 @@ COPY bin ./bin/
# Install dependencies
RUN yarn install --frozen-lockfile && \
# Install curl for performing healthchecks
apk add --no-cache curl && \
apt-get update && apt install -y curl && \
# Compile code
yarn compile && \
# Remove dev dependencies and other unnecessary files
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.cra-runtime
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DOCKER_TAG
FROM staticdeploy/app-server:$DOCKER_TAG
FROM staticdeploy/app-server:$DOCKER_TAG-amd64

# Copy files from cra-runtime stage
ONBUILD COPY --from=0 /app/build /build
Expand Down