diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index e587117c..39b2f23a 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -11,7 +11,7 @@ jobs: timeout-minutes: 1 services: ftpserver: - image: ftpserver/ftpserver + image: fclairamb/ftpserver ports: - 2121-2130:2121-2130 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3cface59..ef428662 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,29 +1,54 @@ -name: Docker Image +name: Docker image v2 on: - push: - release: - types: - - created + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: jobs: - create-docker-image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Setup go - uses: actions/setup-go@v2 - with: - go-version: 1.15 - - - name: Build - run: CGO_ENABLED=0 go build - - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: ftpserver/ftpserver - username: ftpserver - password: ${{ secrets.DOCKER_PASSWORD }} - tag_semver: true + multi-registries: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: fclairamb/ftpserver + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ github.repository_owner }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64 + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index 3d7973fa..6643ad89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,19 @@ # Should be started with: -# docker run -ti -p 2121-2130:2121-2130 ftpserver/ftpserver +# docker run -ti -p 2121-2130:2121-2130 fclairamb/ftpserver + +# Preparing the build environment +FROM golang:1.15-alpine AS builder +ENV GOFLAGS="-mod=readonly" +RUN apk add --update --no-cache bash ca-certificates curl git +RUN mkdir -p /workspace +WORKDIR /workspace + +# Building +COPY . . +RUN go build -v -o ftpserver + +# Preparing the final image FROM alpine:3.12.1 EXPOSE 2121-2130 -COPY ftpserver /bin/ftpserver +COPY --from=builder /workspace/ftpserver /bin/ftpserver ENTRYPOINT [ "/bin/ftpserver" ]