-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support to run with docker (#32)
Adds Dockerfile to build image Adds makefile docker image build Updates readme Renamed pr workflow to Pull Request Renamed tag worflow to Release Improved overall workflows syntax and names Added deploy to dockerhub to Release workflow Updated Makefile command build-docker-image Updated README
- Loading branch information
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
name: tag | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
name: Test | ||
name: Build & Test | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
go-version: '1.17.6' | ||
|
||
- name: Build | ||
run: make build | ||
|
||
- name: Run tests | ||
run: make check | ||
|
||
- name: Upload coverage reports to Codecov with GitHub Action | ||
run: | | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
|
@@ -26,31 +31,40 @@ jobs: | |
tag: | ||
runs-on: ubuntu-latest | ||
needs: build-and-test | ||
name: Generate & Push Tag | ||
|
||
outputs: | ||
tag: ${{ steps.tag_generator.outputs.version_tag }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: tag | ||
|
||
- name: Generate tag | ||
id: tag_generator | ||
uses: paulhatch/[email protected] | ||
with: | ||
tag_prefix: "v" | ||
major_pattern: "(MAJOR)" | ||
minor_pattern: "(MINOR)" | ||
format: "${major}.${minor}.${patch}" | ||
tag_prefix: 'v' | ||
major_pattern: '(MAJOR)' | ||
minor_pattern: '(MINOR)' | ||
format: '${major}.${minor}.${patch}' | ||
short_tags: false | ||
bump_each_commit: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: git | ||
|
||
- name: Push tag to github | ||
run: | | ||
git tag ${{ steps.tag_generator.outputs.version_tag }} | ||
git push origin --tags | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: tag | ||
name: Release | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -68,3 +82,30 @@ jobs: | |
- name: Run GoReleaser | ||
run: make release | ||
|
||
deploy-docker: | ||
runs-on: ubuntu-latest | ||
needs: tag | ||
name: Deploy to DockerHub | ||
|
||
env: | ||
DOCKER_USER: ${{ secrets.DOCKER_USER }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
DOCKER_TAG_LATEST_RELEASE: '${{ secrets.DOCKER_USER }}/mgr8:latest' | ||
DOCKER_TAG_RELEASE: '${{ secrets.DOCKER_USER }}/mgr8:${{ needs.tag.outputs.tag }}' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Docker login | ||
run: | | ||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | ||
- name: Build Docker image | ||
run: | | ||
docker build . --file Dockerfile --tag $DOCKER_TAG_LATEST_RELEASE $DOCKER_TAG_RELEASE | ||
- name: Push to DockerHub | ||
run: | | ||
docker push $DOCKER_TAG_RELEASE | ||
docker push $DOCKER_TAG_LATEST_RELEASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM golang:1.17-alpine3.15 AS builder | ||
|
||
RUN apk add --no-cache git gcc musl-dev make | ||
|
||
WORKDIR /go/src/github.com/migratemgr8/mgr8 | ||
|
||
ENV GO111MODULE=on | ||
|
||
COPY go.mod go.sum ./ | ||
|
||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
RUN make build | ||
|
||
FROM alpine:3.15 | ||
|
||
COPY --from=builder /go/src/github.com/migratemgr8/mgr8/bin/mgr8 /usr/local/bin/mgr8 | ||
RUN ln -s /usr/local/bin/mgr8 /mgr8 | ||
|
||
ENTRYPOINT ["mgr8"] | ||
CMD ["--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ GOLANG_CROSS_VERSION ?= v1.18.2 | |
build: main.go | ||
go build -o bin/mgr8 main.go | ||
|
||
build-docker-image: | ||
docker build . --file Dockerfile --tag migratemgr8/mgr8:latest | ||
|
||
install-tools: | ||
go install github.com/golang/mock/[email protected] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters