diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..8cd29da --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.19-bullseye as build-env + +WORKDIR /usr/src/app +ADD ./ /usr/src/app + +RUN go build -o /app + +FROM gcr.io/distroless/base + +COPY --from=build-env / + +CMD ["/app", "-c", "/app.conf"] diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..11cfdfd --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,41 @@ +name: Docker images build + +on: + push: + tags: + - 'v*' + +jobs: + build-and-push-docker: + runs-on: ubuntu-latest + environment: secure + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set app version + run: V=${{ github.ref_name }} && VT="${V#v}" && sed "s@APP_VERSION@$VT@" misc/version.go.in > misc/version.go + + - name: Login to Registry Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + nixyslab/nxs-support-bot-migrate + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: .docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/misc/version.go.in b/misc/version.go.in new file mode 100644 index 0000000..5244073 --- /dev/null +++ b/misc/version.go.in @@ -0,0 +1,3 @@ +package misc + +const VERSION = "APP_VERSION"