-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: setup docker & cicd github action (#2)
- Loading branch information
1 parent
57e3778
commit a48b52a
Showing
3 changed files
with
88 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Donut Release Build | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Tag version' | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup go version | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.21.0' | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.DOCKER_GITHUB_TOKEN }} | ||
|
||
- name: Set output release tag | ||
id: release | ||
if: github.event_name == 'release' | ||
run: echo ::set-output name=tag::${{ github.event.release.tag_name }} | ||
|
||
- name: Set output release tag | ||
id: dispatch | ||
if: github.event_name == 'workflow_dispatch' | ||
run: echo ::set-output name=tag::${{ github.event.inputs.tag }} | ||
|
||
- name: Build docker image for donut | ||
run: | | ||
RELEASE_VERSION=${{ github.event.release.tag_name }} | ||
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then | ||
RELEASE_VERSION=${{ github.event.inputs.tag }} | ||
fi | ||
RELEASE_VERSION="${RELEASE_VERSION#?}" | ||
echo $RELEASE_VERSION | ||
go version | ||
docker build . -t ghcr.io/mocha-bot/donut:$RELEASE_VERSION -t ghcr.io/mocha-bot/donut:latest | ||
docker push ghcr.io/mocha-bot/donut:$RELEASE_VERSION | ||
docker push ghcr.io/mocha-bot/donut:latest |
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,30 @@ | ||
FROM golang:1.21.0-alpine3.18 as builder | ||
|
||
RUN apk update && apk upgrade && \ | ||
apk --no-cache --update add git make | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN go mod tidy && \ | ||
go mod download && \ | ||
go build -v -o engine && \ | ||
chmod +x engine | ||
|
||
## Distribution | ||
FROM alpine:latest | ||
|
||
# Install dependencies | ||
RUN apk update && apk upgrade && \ | ||
apk --no-cache --update add ca-certificates tzdata && \ | ||
mkdir donut | ||
|
||
# Install Doppler CLI | ||
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected] && \ | ||
echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories && \ | ||
apk add doppler | ||
|
||
WORKDIR /donut | ||
|
||
COPY --from=builder /app/engine /donut |
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