Skip to content

Commit

Permalink
optimize: change slim to alpine due to high build time
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed May 5, 2024
1 parent 40922e8 commit 513d792
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 170 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/canary.yml

This file was deleted.

99 changes: 0 additions & 99 deletions .github/workflows/multi-stage.yml

This file was deleted.

56 changes: 36 additions & 20 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,44 @@ jobs:
run: pnpm install
- name: Run Build
run: pnpm build
build-docker-on-pr:
if: github.event_name == 'pull_request'
needs: build-app
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3

# build-and-push-docker-on-push:
# if: github.event_name == 'push'
# runs-on: ubuntu-latest
# steps:
# - name: Check out the code
# uses: actions/checkout@v3
- name: Prepare .env file
run: |
cp .env.production.example .env.production
- name: Run custom Docker build script
run: |
chmod +x ./docker/build.sh
echo "Building Docker image for ${{ github.base_ref }}"
./docker/build.sh ${{ github.base_ref == 'canary' && 'canary' || '' }}
build-and-push-docker-on-push:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- 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: 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: 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' || '' }}
- name: Build and push Docker image using custom script
run: |
chmod +x ./docker/push.sh
./docker/push.sh ${{ github.ref_name == 'canary' && 'canary' || '' }}
3 changes: 1 addition & 2 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ else
TAG="$VERSION"
fi


docker build --platform=linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:${TAG}" -f 'Dockerfile' .
docker buildx build --platform linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:${TAG}" -f 'Dockerfile' .

3 changes: 0 additions & 3 deletions docker/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Determine the type of build based on the first script argument
BUILD_TYPE=${1:-production}

BUILDER=$(docker buildx create --use)

if [ "$BUILD_TYPE" == "canary" ]; then
TAG="canary"
Expand All @@ -14,5 +13,3 @@ else
VERSION=$(node -p "require('./package.json').version")
docker buildx build --platform linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:latest" -t "dokploy/dokploy:${VERSION}" -f 'Dockerfile' --push .
fi

docker buildx rm $BUILDER

0 comments on commit 513d792

Please sign in to comment.