From 3d9b196d31d6b4738e6c5fa4f41379550b9e751d Mon Sep 17 00:00:00 2001 From: cubicroot Date: Sun, 26 May 2024 14:22:17 +0200 Subject: [PATCH] build and publish image --- .github/workflows/release.yml | 25 +++++++++++++++++++++++++ Dockerfile | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4e52d47 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Release +on: + release: + types: [published] + +jobs: + # Builds the image and publishes it on docker hub + build_and_push_docker: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + - name: Build container + run: docker build --build-arg VERSION=${{ github.ref_name }} -t cubicrootxyz/trollinfo:latest . + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push image (latest) + run: docker push cubicrootxyz/remindme:latest + - name: Tag image with version + run: docker tag cubicrootxyz/remindme:latest cubicrootxyz/remindme:${{ github.event.release.tag_name }} + - name: Push image (version) + run: docker push cubicrootxyz/remindme:${{ github.event.release.tag_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..355b4b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.22 as builder +ARG VERSION="development" + +WORKDIR /run + +COPY ./ ./ +RUN go mod download +RUN go build -ldflags="-w -s -X github.com/CubicrootXYZ/matrix-reminder-and-calendar-bot/cmd.Version=${VERSION}" -o /run ./cmd/remindme + +FROM golang:1.22 +RUN apt update && apt upgrade -y && \ + apt install -y gcc && \ + apt install libolm-dev npm -y +COPY --from=builder /run/remindme /run/ +WORKDIR /run + +CMD ["/run/remindme"] \ No newline at end of file