diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a1de6f6..77cc1081 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,8 @@ name: Docker builds +env: + TARGET_PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + on: schedule: - cron: "0 10 * * *" # everyday at 10am @@ -27,12 +30,20 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: ${{ env.TARGET_PLATFORMS }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Prepare id: prepare run: | DOCKER_USERNAME=viktorstrate DOCKER_IMAGE=viktorstrate/photoview - DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + DOCKER_PLATFORMS=${TARGET_PLATFORMS} VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then @@ -53,6 +64,7 @@ jobs: echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=version::${VERSION} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ + --progress=plain \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ --build-arg VERSION=${VERSION} \ @@ -60,10 +72,7 @@ jobs: --build-arg VCS_REF=${GITHUB_SHA::8} \ ${TAGS} --file Dockerfile . - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Docker Buildx (build) + - name: Build Docker images run: | docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} @@ -74,7 +83,7 @@ jobs: run: | echo "${DOCKER_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin - - name: Docker Buildx (push) + - name: Push to Docker Hub if: success() && github.event_name != 'pull_request' && github.repository == 'viktorstrate/photoview' run: | docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} diff --git a/Dockerfile b/Dockerfile index de1361bb..814f8fd7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,9 @@ RUN npm run build -- --public-url $UI_PUBLIC_URL FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.14-alpine AS api COPY --from=tonistiigi/xx:golang / / +ARG TARGETPLATFORM +RUN go env + RUN mkdir -p /app WORKDIR /app @@ -33,18 +36,13 @@ RUN go mod download # Copy api source COPY api /app -ARG TARGETPLATFORM -ARG TARGETOS -ARG TARGETARCH - -RUN go env RUN go build -v -o photoview . # Copy api and ui to production environment FROM alpine:3.12 # Install darktable for converting RAW images, and ffmpeg for encoding videos -# Ignore errors if packages are not supported for the specified platform +# Ignore errors if packages are not supported for the specific platform RUN apk --no-cache add darktable; exit 0 RUN apk --no-cache add ffmpeg; exit 0