Add Dockerfile and build with GitHub Actions

This commit is contained in:
2024-01-21 20:42:56 +01:00
parent 1224498518
commit 5e3543c392
4 changed files with 50 additions and 0 deletions

32
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Test and Build Docker Image
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event_name != 'pull_request'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/thelovinator1/anewdawn:latest

View File

@ -1,5 +1,6 @@
{
"cSpell.words": [
"anewdawn",
"bwmarrin",
"discordgo",
"godotenv",

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM golang:1.21-alpine
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /usr/local/bin/app ./...
CMD ["app"]

5
docker-compose.yml Normal file
View File

@ -0,0 +1,5 @@
services:
anewdawn:
image: ghcr.io/thelovinator1/anewdawn:master
container_name: anewdawn
restart: unless-stopped