feat: add arm64 docker image build (#3262)
* Add arm64 docker image build * add arm64 docker image build * fix: install missing docker buildx * fix: new cimg orbs not working with this config * fix misstake on qemu image name * fix node:16 image not supported on arm/v5 and arm/v6 * add timeout to avoir errors * fix docker buildx multiarch auto removing * remove useless platforms, and keep only most used to reduce CI duration * fix context issues * fixed multiarch CI
This commit is contained in:
@@ -25,6 +25,7 @@ executors:
|
|||||||
docker-publisher:
|
docker-publisher:
|
||||||
environment:
|
environment:
|
||||||
IMAGE_NAME: outlinewiki/outline
|
IMAGE_NAME: outlinewiki/outline
|
||||||
|
BASE_IMAGE_NAME: outlinewiki/outline-base
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/base
|
- image: cimg/base
|
||||||
|
|
||||||
@@ -97,50 +98,36 @@ jobs:
|
|||||||
- setup_remote_docker:
|
- setup_remote_docker:
|
||||||
version: 20.10.6
|
version: 20.10.6
|
||||||
- run:
|
- run:
|
||||||
name: Build Docker image
|
name: Install Docker buildx
|
||||||
command: docker build -t $IMAGE_NAME:latest .
|
|
||||||
- run:
|
|
||||||
name: Archive Docker image
|
|
||||||
command: docker save -o image.tar $IMAGE_NAME
|
|
||||||
- persist_to_workspace:
|
|
||||||
root: .
|
|
||||||
paths:
|
|
||||||
- ./image.tar
|
|
||||||
publish-latest:
|
|
||||||
executor: docker-publisher
|
|
||||||
steps:
|
|
||||||
- attach_workspace:
|
|
||||||
at: /tmp/workspace
|
|
||||||
- setup_remote_docker:
|
|
||||||
version: 20.10.6
|
|
||||||
- run:
|
|
||||||
name: Load archived Docker image
|
|
||||||
command: docker load -i /tmp/workspace/image.tar
|
|
||||||
- run:
|
|
||||||
name: Publish Docker Image to Docker Hub
|
|
||||||
command: |
|
command: |
|
||||||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
mkdir -p ~/.docker/cli-plugins
|
||||||
IMAGE_TAG=${CIRCLE_TAG/v/''}
|
url="https://github.com/docker/buildx/releases/download/v0.8.0/buildx-v0.8.0.linux-amd64"
|
||||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
|
curl -sSL -o ~/.docker/cli-plugins/docker-buildx $url
|
||||||
docker push $IMAGE_NAME:latest
|
chmod a+x ~/.docker/cli-plugins/docker-buildx
|
||||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
|
||||||
publish-tag:
|
|
||||||
executor: docker-publisher
|
|
||||||
steps:
|
|
||||||
- attach_workspace:
|
|
||||||
at: /tmp/workspace
|
|
||||||
- setup_remote_docker:
|
|
||||||
version: 20.10.6
|
|
||||||
- run:
|
- run:
|
||||||
name: Load archived Docker image
|
name: Enable Docker buildx
|
||||||
command: docker load -i /tmp/workspace/image.tar
|
command: export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
- run:
|
- run:
|
||||||
name: Publish Docker Image to Docker Hub
|
name: Initialize Docker buildx
|
||||||
command: |
|
command: |
|
||||||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
docker buildx install
|
||||||
IMAGE_TAG=${CIRCLE_TAG/v/''}
|
docker context create docker-multiarch
|
||||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
docker buildx create --name docker-multiarch --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x docker-multiarch
|
||||||
|
docker buildx inspect --builder docker-multiarch --bootstrap
|
||||||
|
docker buildx use docker-multiarch
|
||||||
|
- run:
|
||||||
|
name: Build base image
|
||||||
|
command: docker build -f Dockerfile.base -t $BASE_IMAGE_NAME:latest --load .
|
||||||
|
- run:
|
||||||
|
name: Login to Docker Hub
|
||||||
|
command: echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||||
|
- run:
|
||||||
|
name: Publish base Docker Image to Docker Hub
|
||||||
|
command: docker push $BASE_IMAGE_NAME:latest
|
||||||
|
- run:
|
||||||
|
name: Build and push Docker image
|
||||||
|
command: docker buildx build -t $IMAGE_NAME:latest -t $IMAGE_NAME:${CIRCLE_TAG/v/''} --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x --push .
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
@@ -172,19 +159,3 @@ workflows:
|
|||||||
only: /^v.*/
|
only: /^v.*/
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
- publish-latest:
|
|
||||||
requires:
|
|
||||||
- build-image
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /^v\d+\.\d+\.\d+$/
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
- publish-tag:
|
|
||||||
requires:
|
|
||||||
- build-image
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /^v\d+\.\d+\.\d+-.*$/
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
|
|||||||
39
Dockerfile
39
Dockerfile
@@ -1,45 +1,22 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG APP_PATH=/opt/outline
|
ARG APP_PATH=/opt/outline
|
||||||
FROM node:16-alpine AS deps-common
|
FROM outlinewiki/outline-base as base
|
||||||
|
|
||||||
ARG APP_PATH
|
|
||||||
WORKDIR $APP_PATH
|
|
||||||
COPY ./package.json ./yarn.lock ./
|
|
||||||
|
|
||||||
# ---
|
|
||||||
FROM deps-common AS deps-dev
|
|
||||||
RUN yarn install --no-optional --frozen-lockfile && \
|
|
||||||
yarn cache clean
|
|
||||||
|
|
||||||
# ---
|
|
||||||
FROM deps-common AS deps-prod
|
|
||||||
RUN yarn install --production=true --frozen-lockfile && \
|
|
||||||
yarn cache clean
|
|
||||||
|
|
||||||
# ---
|
|
||||||
FROM node:16-alpine AS builder
|
|
||||||
|
|
||||||
ARG APP_PATH
|
ARG APP_PATH
|
||||||
WORKDIR $APP_PATH
|
WORKDIR $APP_PATH
|
||||||
|
|
||||||
COPY . .
|
|
||||||
COPY --from=deps-dev $APP_PATH/node_modules ./node_modules
|
|
||||||
ARG CDN_URL
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
FROM node:16-alpine AS runner
|
FROM node:16.14.2-alpine3.15 AS runner
|
||||||
|
|
||||||
ARG APP_PATH
|
ARG APP_PATH
|
||||||
WORKDIR $APP_PATH
|
WORKDIR $APP_PATH
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
COPY --from=builder $APP_PATH/build ./build
|
COPY --from=base $APP_PATH/build ./build
|
||||||
COPY --from=builder $APP_PATH/server ./server
|
COPY --from=base $APP_PATH/server ./server
|
||||||
COPY --from=builder $APP_PATH/public ./public
|
COPY --from=base $APP_PATH/public ./public
|
||||||
COPY --from=builder $APP_PATH/.sequelizerc ./.sequelizerc
|
COPY --from=base $APP_PATH/.sequelizerc ./.sequelizerc
|
||||||
COPY --from=deps-prod $APP_PATH/node_modules ./node_modules
|
COPY --from=base $APP_PATH/node_modules ./node_modules
|
||||||
COPY --from=builder $APP_PATH/package.json ./package.json
|
COPY --from=base $APP_PATH/package.json ./package.json
|
||||||
|
|
||||||
RUN addgroup -g 1001 -S nodejs && \
|
RUN addgroup -g 1001 -S nodejs && \
|
||||||
adduser -S nodejs -u 1001 && \
|
adduser -S nodejs -u 1001 && \
|
||||||
|
|||||||
18
Dockerfile.base
Normal file
18
Dockerfile.base
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
ARG APP_PATH=/opt/outline
|
||||||
|
FROM node:16.14.2-alpine3.15 AS deps
|
||||||
|
|
||||||
|
ARG APP_PATH
|
||||||
|
WORKDIR $APP_PATH
|
||||||
|
COPY ./package.json ./yarn.lock ./
|
||||||
|
|
||||||
|
RUN yarn install --no-optional --frozen-lockfile --network-timeout 1000000 && \
|
||||||
|
yarn cache clean
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
ARG CDN_URL
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
RUN rm -rf node_modules
|
||||||
|
|
||||||
|
RUN yarn install --production=true --frozen-lockfile --network-timeout 1000000 && \
|
||||||
|
yarn cache clean
|
||||||
Reference in New Issue
Block a user