Skip to content

Commit eaa2c9c

Browse files
feat: docker compatibility, docker compose github build and such
1 parent f77b507 commit eaa2c9c

6 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Nightly Docker Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Log in to GHCR
19+
uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Generate metadata
26+
id: meta
27+
uses: docker/metadata-action@v5
28+
with:
29+
images: ghcr.io/${{ github.repository }}
30+
tags: |
31+
type=raw,value=nightly
32+
type=sha
33+
34+
- name: Build and push
35+
uses: docker/build-push-action@v5
36+
with:
37+
context: .
38+
push: true
39+
tags: ${{ steps.meta.outputs.tags }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release Docker Build
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Log in to GHCR
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Generate metadata
27+
id: meta
28+
uses: docker/metadata-action@v5
29+
with:
30+
images: ghcr.io/${{ github.repository }}
31+
tags: |
32+
type=semver,pattern={{version}}
33+
type=semver,pattern={{major}}.{{minor}}
34+
type=raw,value=latest
35+
36+
- name: Build and push
37+
uses: docker/build-push-action@v5
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang:1.25.0 AS build
2+
WORKDIR /app
3+
COPY src/ .
4+
RUN go build .
5+
6+
FROM debian:latest
7+
COPY --from=build /app/sine /
8+
EXPOSE 8080
9+
ENTRYPOINT [ "/sine" ]

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
services:
2+
3+
sine:
4+
image: ghcr.io/blacklizardcode/sine:latest
5+
container_name: sine
6+
restart: always
7+
environment:
8+
- JWT_KEY=smtn
9+
- DB_USER=root
10+
- DB_PASS=root
11+
- DB_URI=127.0.0.1:5432
12+
- DB_NAME=sine-db
13+
214
postgres:
315
image: postgres
416
container_name: postgres_db

setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/sh
22

3+
4+
35
docker compose up -d

src/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
func main() {
1919
slog.SetDefault(slog.New(slogcolor.NewHandler(os.Stderr, slogcolor.DefaultOptions)))
20+
slog.SetLogLoggerLevel(slog.LevelInfo)
2021

2122
slog.Info("starting")
2223

0 commit comments

Comments
 (0)