diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1ca05d..23d5bac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,17 +26,21 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to the Container registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ env.DOCKERHUB_USERNAME }} + password: ${{ env.DOCKERHUB_TOKEN }} - name: Build and Push uses: docker/build-push-action@v5 with: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile index 41aa4eb..5e74ded 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,26 @@ -FROM alpine:3.9.3 +# syntax=docker/dockerfile:1 + +FROM golang:1.21-alpine AS builder + +COPY . /build +WORKDIR /build +RUN go mod download + +RUN CGO_ENABLED=0 \ + go build \ + -trimpath \ + -ldflags="-w -s" \ + -o chrly \ + main.go + +FROM alpine:3.19 EXPOSE 80 - -RUN apk add --no-cache ca-certificates - ENV STORAGE_REDIS_HOST=redis ENV STORAGE_FILESYSTEM_HOST=/data -COPY docker-entrypoint.sh /usr/local/bin/ -COPY release/chrly /usr/local/bin/ +COPY docker-entrypoint.sh / +COPY --from=builder /build/chrly /usr/local/bin/chrly -ENTRYPOINT ["docker-entrypoint.sh"] +ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["serve"]