Fix(Builds): Make docker builds 98% faster (#250)

Feat: add circle ci as a runner
This commit is contained in:
Mauricio Siu
2024-07-22 03:14:25 -06:00
committed by GitHub
parent 701319efdd
commit b7c061dcb4
4 changed files with 252 additions and 35 deletions

View File

@@ -0,0 +1,72 @@
version: 2.1
jobs:
build-amd64:
machine:
image: ubuntu-2004:current
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push AMD64 image
command: |
VERSION=$(node -p "require('./package.json').version")
echo $VERSION
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker build --platform linux/amd64 -t dokploy/dokploy:canary-amd64 .
docker push dokploy/dokploy:canary-amd64
build-arm64:
machine:
image: ubuntu-2004:current
resource_class: arm.large
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push ARM64 image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker build --platform linux/arm64 -t dokploy/dokploy:canary-arm64 .
docker push dokploy/dokploy:canary-arm64
combine-manifests:
docker:
- image: cimg/base:stable
steps:
- setup_remote_docker
- run:
name: Create and push multi-arch manifest
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker manifest create dokploy/dokploy:canary \
dokploy/dokploy:canary-amd64 \
dokploy/dokploy:canary-arm64
docker manifest push dokploy/dokploy:canary
workflows:
version: 2
build-all:
jobs:
- build-amd64:
filters:
branches:
only: feat/circle
- build-arm64:
filters:
branches:
only: feat/circle
- combine-manifests:
requires:
- build-amd64
- build-arm64
filters:
branches:
only: feat/circle

104
.circleci/config.yml Normal file
View File

@@ -0,0 +1,104 @@
version: 2.1
jobs:
build-amd64:
machine:
image: ubuntu-2004:current
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push AMD64 image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
if [ "${CIRCLE_BRANCH}" == "main" ]; then
TAG="latest"
else
TAG="canary"
fi
docker build --platform linux/amd64 -t dokploy/dokploy:${TAG}-amd64 .
docker push dokploy/dokploy:${TAG}-amd64
build-arm64:
machine:
image: ubuntu-2004:current
resource_class: arm.large
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push ARM64 image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
if [ "${CIRCLE_BRANCH}" == "main" ]; then
TAG="latest"
else
TAG="canary"
fi
docker build --platform linux/arm64 -t dokploy/dokploy:${TAG}-arm64 .
docker push dokploy/dokploy:${TAG}-arm64
combine-manifests:
docker:
- image: cimg/base:stable
steps:
- checkout
- setup_remote_docker
- run:
name: Create and push multi-arch manifest
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
if [ "${CIRCLE_BRANCH}" == "main" ]; then
VERSION=$(node -p "require('./package.json').version")
echo $VERSION
TAG="latest"
docker manifest create dokploy/dokploy:${TAG} \
dokploy/dokploy:${TAG}-amd64 \
dokploy/dokploy:${TAG}-arm64
docker manifest push dokploy/dokploy:${TAG}
docker manifest create dokploy/dokploy:${VERSION} \
dokploy/dokploy:${TAG}-amd64 \
dokploy/dokploy:${TAG}-arm64
docker manifest push dokploy/dokploy:${VERSION}
else
TAG="canary"
docker manifest create dokploy/dokploy:${TAG} \
dokploy/dokploy:${TAG}-amd64 \
dokploy/dokploy:${TAG}-arm64
docker manifest push dokploy/dokploy:${TAG}
fi
workflows:
version: 2
build-all:
jobs:
- build-amd64:
filters:
branches:
only:
- main
- canary
- build-arm64:
filters:
branches:
only:
- main
- canary
- combine-manifests:
requires:
- build-amd64
- build-arm64
filters:
branches:
only:
- main
- canary

76
.circleci/main-config.yml Normal file
View File

@@ -0,0 +1,76 @@
version: 2.1
jobs:
build-amd64:
machine:
image: ubuntu-2004:current
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push AMD64 image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker build --platform linux/amd64 -t dokploy/dokploy:latest-amd64 .
docker push dokploy/dokploy:latest-amd64
build-arm64:
machine:
image: ubuntu-2004:current
resource_class: arm.large
steps:
- checkout
- run:
name: Prepare .env file
command: |
cp .env.production.example .env.production
- run:
name: Build and push ARM64 image
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker build --platform linux/arm64 -t dokploy/dokploy:latest-arm64 .
docker push dokploy/dokploy:latest-arm64
combine-manifests:
docker:
- image: cimg/base:stable
steps:
- setup_remote_docker
- run:
name: Create and push multi-arch manifest
command: |
VERSION=$(node -p "require('./package.json').version")
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN
docker manifest create dokploy/dokploy:latest \
dokploy/dokploy:latest-amd64 \
dokploy/dokploy:latest-arm64
docker manifest push dokploy/dokploy:latest
docker manifest create dokploy/dokploy:${VERSION} \
dokploy/dokploy:latest-amd64 \
dokploy/dokploy:latest-arm64
docker manifest push dokploy/dokploy:${VERSION}
workflows:
version: 2
build-all:
jobs:
- build-amd64:
filters:
branches:
only: main
- build-arm64:
filters:
branches:
only: main
- combine-manifests:
requires:
- build-amd64
- build-arm64
filters:
branches:
only: main

View File

@@ -1,35 +0,0 @@
name: Push
on:
push:
branches:
- main
- canary
env:
HUSKY: 0
jobs:
build-and-push-docker-on-push:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare .env file
run: |
cp .env.production.example .env.production
- name: Build and push Docker image using custom script
run: |
chmod +x ./docker/push.sh
./docker/push.sh ${{ github.ref_name == 'canary' && 'canary' || '' }}