diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..e139fc9 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,59 @@ +--- +kind: pipeline +type: docker +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: + - name: publish + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + registry: gitea.dwysokinski.me + repo: gitea.dwysokinski.me/zdam-egzamin-zawodowy-docker/backend + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: ./build/server/Dockerfile + +trigger: + event: + - tag +--- +kind: pipeline +type: docker +name: manifest + +steps: + - name: manifest + image: plugins/manifest + settings: + auto_tag: "true" + ignore_missing: "true" + spec: manifest.tmpl + username: + from_secret: docker_username + password: + from_secret: docker_password + - name: manifest-latest + image: plugins/manifest + settings: + tags: latest + ignore_missing: "true" + spec: ./build/server/manifest.tmpl + username: + from_secret: docker_username + password: + from_secret: docker_password + +trigger: + event: + - tag + +depends_on: + - linux-amd64 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 31f6e2d..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and push to registry - -on: - push: - tags: - - '*' - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - 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: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.REGISTRY_LOGIN }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Push to Docker Hub - uses: docker/build-push-action@v3 - with: - context: . - build-args: | - VERSION=${{ steps.get_version.outputs.VERSION }} - tags: | - ${{ secrets.REGISTRY_NAME }}/zdam-egzamin-zawodowy-backend:latest - ${{ secrets.REGISTRY_NAME }}/zdam-egzamin-zawodowy-backend:${{ steps.get_version.outputs.VERSION }} - file: ./build/server/Dockerfile - push: true diff --git a/build/server/Dockerfile b/build/server/Dockerfile index 1ea0d63..6e3b443 100644 --- a/build/server/Dockerfile +++ b/build/server/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:alpine as builder +FROM golang:1.19-alpine3.16 as builder # Set the Current Working Directory inside the container WORKDIR /app @@ -19,7 +19,7 @@ ENV CGO_ENABLED=0 RUN go build -ldflags="-X 'main.Version=$VERSION'" -o zdamegzawodowy ./cmd/server ######## Start a new stage from scratch ####### -FROM alpine:latest +FROM alpine:3.16 RUN apk --no-cache add ca-certificates diff --git a/build/server/manifest.tmpl b/build/server/manifest.tmpl new file mode 100644 index 0000000..8556f2e --- /dev/null +++ b/build/server/manifest.tmpl @@ -0,0 +1,13 @@ +image: gitea.dwysokinski.me/zdam-egzamin-zawodowy-docker/backend:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - + image: gitea.dwysokinski.me/zdam-egzamin-zawodowy-docker/backend:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux