Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker #3

Merged
merged 5 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ 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 --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' }}
run: |
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, you can run `datasubst` via Docker instead:

```shell
docker run --rm ghcr.io/marcelocarlos/datasubst:v0
```

## Usage

```shell
Expand Down