From 145d6e62e7b21fb30855c46ba04e4bb9b38e78aa Mon Sep 17 00:00:00 2001 From: Marcelo Carlos Date: Fri, 29 Oct 2021 18:28:17 +0100 Subject: [PATCH 1/5] Add Docker image --- .github/workflows/build.yaml | 19 +++++++++++++++++++ Dockerfile | 13 +++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index abee931..1d37e15 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -64,6 +64,25 @@ jobs: }); } + - name: Log in to the Container registry + # if: ${{ github.event_name == 'release' }} + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push image + # if: ${{ github.event_name == 'release' }} + run: | + VERSION=$(git describe --tags) + + docker build -t ghcr.io/${{ github.repository }}:latest + docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${VERSION} + + docker push ghcr.io/${{ github.repository }}:latest + docker push ghcr.io/${{ github.repository }}:${VERSION} + - name: Trigger homebrew tap update if: ${{ github.event_name == 'release' }} run: | diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..215d796 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:alpine AS builder +# Git is required to fetch the dependencies +RUN apk update && apk add --no-cache git +WORKDIR /build +COPY . . +RUN go get -d -v +RUN go build -o /build/datasubst + + +FROM scratch +COPY --from=builder /build/datasubst /datasubst +ENTRYPOINT ["/datasubst"] + From 6c89ffc800c11d5e6d6b49b0ac075a95334ab81a Mon Sep 17 00:00:00 2001 From: Marcelo Carlos Date: Fri, 29 Oct 2021 18:32:11 +0100 Subject: [PATCH 2/5] typo --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1d37e15..a078105 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -77,7 +77,7 @@ jobs: run: | VERSION=$(git describe --tags) - docker build -t ghcr.io/${{ github.repository }}:latest + docker build -t ghcr.io/${{ github.repository }}:latest . docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${VERSION} docker push ghcr.io/${{ github.repository }}:latest From b2981a0e69178a5a41b5ff6d26b3acab56d6fc40 Mon Sep 17 00:00:00 2001 From: Marcelo Carlos Date: Fri, 29 Oct 2021 18:42:59 +0100 Subject: [PATCH 3/5] Add more tags --- .github/workflows/build.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a078105..32964d5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -75,13 +75,17 @@ jobs: - name: Build and Push image # if: ${{ github.event_name == 'release' }} run: | - VERSION=$(git describe --tags) + VERSION=$(git describe --tags --abbrev=0) docker build -t ghcr.io/${{ github.repository }}:latest . docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${VERSION} + docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${VERSION:0:4} + docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${VERSION:0:2} docker push ghcr.io/${{ github.repository }}:latest docker push ghcr.io/${{ github.repository }}:${VERSION} + docker push ghcr.io/${{ github.repository }}:${VERSION:0:4} + docker push ghcr.io/${{ github.repository }}:${VERSION:0:2} - name: Trigger homebrew tap update if: ${{ github.event_name == 'release' }} From bddd64084710a8672218638bc48389678cacfa84 Mon Sep 17 00:00:00 2001 From: Marcelo Carlos Date: Fri, 29 Oct 2021 18:55:36 +0100 Subject: [PATCH 4/5] Update README --- .github/workflows/build.yaml | 4 ++-- README.md | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 32964d5..86a4e02 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -65,7 +65,7 @@ jobs: } - name: Log in to the Container registry - # if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'release' }} uses: docker/login-action@v1 with: registry: ghcr.io @@ -73,7 +73,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push image - # if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'release' }} run: | VERSION=$(git describe --tags --abbrev=0) diff --git a/README.md b/README.md index 1d32aa3..b834ddd 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ Alternatively, you can install a development version using: go get github.com/marcelocarlos/datasubst ``` +If you don't want to install it and run it via Docker instead: + +```shell +docker run --rm ghcr.io/marcelocarlos/datasubst:v0 +``` + ## Usage ```shell From 16d647bce34caeb7ecc30e44f073444fdd34c3b6 Mon Sep 17 00:00:00 2001 From: Marcelo Carlos Date: Fri, 29 Oct 2021 18:56:52 +0100 Subject: [PATCH 5/5] docker instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b834ddd..ebec3f2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Alternatively, you can install a development version using: go get github.com/marcelocarlos/datasubst ``` -If you don't want to install it and run it via Docker instead: +If you don't want to install it, you can run `datasubst` via Docker instead: ```shell docker run --rm ghcr.io/marcelocarlos/datasubst:v0