Skip to content

Commit

Permalink
fix docker and try to build with cache in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaprar committed Jul 1, 2024
1 parent 3a7ba20 commit ec90296
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,19 @@ jobs:
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --platform linux/arm64

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
push: true
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/alcaprar/localgems:latest
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ WORKDIR /home/app/backend
COPY ./backend /home/app/backend/
RUN NODE_ENV=production yarn build

COPY --from=frontend-builder /home/app/frontend/.output/server /home/app/frontend/.output/server
COPY --from=frontend-builder /home/app/frontend/.output /home/app/frontend/.output

COPY ./entrypoint.sh /home/app/entrypoint.sh

Expand Down

0 comments on commit ec90296

Please sign in to comment.