diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml new file mode 100644 index 0000000..57e3400 --- /dev/null +++ b/.github/workflows/matrix-build.yml @@ -0,0 +1,73 @@ +name: docker + +on: + push: + tags: + - "v*" + +env: + DOCKER_REPO: username/testapp + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 30 + + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + + steps: + - name: Set vars + id: vars + run: | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + echo "platform=$(echo -n ${{ matrix.platform }} | sed 's/\//-/g')" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build docker images + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: ${{ matrix.platform }} + tags: | + ${{ env.DOCKER_REPO }}:${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.platform }} + + release: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: build + + steps: + - name: Set vars + id: vars + run: | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Create Docker Hub manifest + run: | + docker manifest create $DOCKER_REPO:${{ steps.vars.outputs.version }} \ + $DOCKER_REPO:${{ steps.vars.outputs.version }}-linux-amd64 \ + $DOCKER_REPO:${{ steps.vars.outputs.version }}-linux-arm64 + + - name: Push manifests + run: | + docker manifest push $DOCKER_REPO:${{ steps.vars.outputs.version }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d56d4a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# +# MailHog Dockerfile +# + +FROM golang:1.21-alpine as builder + +# Install MailHog: +RUN apk --no-cache add --virtual build-dependencies \ + git \ + && mkdir -p /root/gocode \ + && export GOPATH=/root/gocode \ + && go install github.com/mailhog/MailHog@latest + +FROM alpine:3 +# Add mailhog user/group with uid/gid 1000. +# This is a workaround for boot2docker issue #581, see +# https://github.com/boot2docker/boot2docker/issues/581 +RUN adduser -D -u 1000 mailhog + +COPY --from=builder /root/gocode/bin/MailHog /usr/local/bin/ + +USER mailhog + +WORKDIR /home/mailhog + +ENTRYPOINT ["MailHog"] + +# Expose the SMTP and HTTP ports: +EXPOSE 1025 8025