Skip to content

Commit

Permalink
More docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Jan 13, 2024
1 parent 2cd4ac3 commit a959a80
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
33 changes: 9 additions & 24 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
# IDE folders
.idea/
.vscode/
./src-ui/.vscode
# OS turds
.DS_Store
# VCS
.git
.github
# App files
*.http
*.sql
.env
.env.example
.gitignore
app.json
flake.lock
flake.nix
fly.toml
http-client.private.env.json
LICENSE
Procfile
README.md
docker-compose.yml
*
!bot/
!logger/
!model/
!plugin/
!utils/
!go.mod
!go.sum
!main.go
36 changes: 34 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
GOOS: [ windows, linux ]
GOARCH: [ amd64, arm ]
GOOS: [windows, linux]
GOARCH: [amd64, arm]
exclude:
- GOOS: windows
GOARCH: arm
Expand Down Expand Up @@ -55,3 +55,35 @@ jobs:
path: dist/*
retention-days: 90

docker:
name: docker
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build . --file Dockerfile --tag $NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$NAME
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /gobot

FROM gcr.io/distroless/base-debian12 AS release-stage
WORKDIR /gobot
COPY --from=build-stage /gobot /gobot/gobot
FROM gcr.io/distroless/static-debian12 AS release-stage
WORKDIR /app
COPY --from=build-stage /gobot /app/gobot
USER nonroot:nonroot
ENTRYPOINT ["/gobot/gobot"]
ENTRYPOINT ["/app/gobot"]
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ version: '3.8'
name: gobot
services:
bot:
build: .
# build: .
pull_policy: always
image: ghcr.io/brawl345/gobot:latest
restart: always
user: '${DOCKER_UID}:${DOCKER_GID}'
env_file: .env
Expand Down

0 comments on commit a959a80

Please sign in to comment.