4 Commits

Author SHA1 Message Date
5df1e9485a Add support for database path from environment variable
All checks were successful
Build / build (push) Successful in 2m43s
Deploy / build (push) Successful in 3m57s
2025-03-24 12:45:29 +01:00
d0af018510 Fix dockerfile 2025-03-24 12:43:34 +01:00
7d938d0c26 Add Dockerfile for building and running the application
All checks were successful
Build / build (push) Successful in 53s
2025-03-24 12:42:25 +01:00
82edcc51a7 Add build step to GitHub Actions and rename deploy job
All checks were successful
Build / build (push) Successful in 1m22s
2025-03-24 12:39:46 +01:00
4 changed files with 26 additions and 2 deletions

View File

@@ -12,5 +12,8 @@ jobs:
with:
go-version: '>=1.24'
- name: Build
run: go build .
- name: Test
run: go test . -v

View File

@@ -1,4 +1,4 @@
name: Build
name: Deploy
on:
push:
tags:

13
Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM golang:1.24.1-alpine3.21
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY migrations ./migrations
COPY static ./static
COPY templates ./templates
COPY *.go ./
RUN go build -o /pcinv
CMD ["/pcinv"]

10
main.go
View File

@@ -5,6 +5,7 @@ import (
"html/template"
"log"
"net/http"
"os"
"gitea.seeseepuff.be/seeseemelk/mysqlite"
"github.com/gin-gonic/gin"
@@ -18,7 +19,14 @@ var templateFS embed.FS
func main() {
log.Println("Starting...")
db, err := mysqlite.OpenDb("pcinv.db3")
// Get database path from environment variable or use default
dbPath := os.Getenv("PCINV_DB")
if dbPath == "" {
dbPath = "pcinv.db3"
}
db, err := mysqlite.OpenDb(dbPath)
if err != nil {
log.Fatalf("error opening db: %v", err)
}