diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..11b65fb --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index ee5c4c5..e436c5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "anewdawn", "bwmarrin", "discordgo", "godotenv", diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ff0a351 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5798f84 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +services: + anewdawn: + image: ghcr.io/thelovinator1/anewdawn:master + container_name: anewdawn + restart: unless-stopped