Skip to content

Commit

Permalink
Merge pull request #21 from ipfs/docker-build-test
Browse files Browse the repository at this point in the history
Attempt to get docker builds going
  • Loading branch information
hsanjuan authored Oct 13, 2023
2 parents 576ac0a + 617ebcb commit 5f521d8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create and publish a Docker image

on:
push:
branches: ['main']
tags: ['v*']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get tags
id: tags
env:
IMAGE_NAME: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
echo "value<<EOF" >> $GITHUB_OUTPUT
./docker/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Build Docker image and publish to Docker Hub
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
context: .
push: true
file: ./Dockerfile
tags: "${{ steps.tags.outputs.value }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache to limit growth
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.20-bullseye AS builder

LABEL org.opencontainers.image.source=https://github.com/ipfs/rainbow
LABEL org.opencontainers.image.description="A stand-alone IPFS Gateway"
LABEL org.opencontainers.image.licenses=MIT+APACHE_2.0


# This builds rainbow

ARG TARGETPLATFORM TARGETOS TARGETARCH
Expand Down
1 change: 0 additions & 1 deletion docker/get-docker-tags.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ elif [ "$GIT_BRANCH" = "main" ]; then
echoImageName "main-${BUILD_NUM}-${GIT_SHA1_SHORT}"
echoImageName "main-latest"


else
echo "Nothing to do. No docker tag defined for branch: $GIT_BRANCH, tag: $GIT_TAG"

Expand Down

0 comments on commit 5f521d8

Please sign in to comment.