A Dockerfile => Dockerfile +25 -0
@@ 0,0 1,25 @@
+# builder
+FROM golang:1.20.1-alpine AS builder
+
+WORKDIR /usr/src/app
+
+COPY go.mod go.sum ./
+RUN go mod download && go mod verify
+
+COPY . .
+
+RUN CGO_ENABLED=0 GOOS=linux go build -v -o /tixe ./tixe.go
+
+# tester
+FROM builder AS tester
+RUN go test -v ./...
+
+# release
+FROM alpine:3.18 AS release
+
+COPY --from=builder /tixe /tixe
+ADD ./static /static
+
+EXPOSE 8080
+
+ENTRYPOINT ["/tixe"]
M dev.elv => dev.elv +29 -10
@@ 2,25 2,44 @@
fn run {
clear
- go run tixe.go
+ docker compose up --build
}
-fn build {
+fn clean {
clear
- go build
+ docker compose down
+ docker volume rm tixe_tixedb_data
+}
+
+fn docker_menu {
+ var input
+ while (not-eq $input "b") {
+ echo "[R]un, [C]lean, [B]ack"
+ set input = (sh -c 'read -n1 && echo $REPLY' | take 1)
+
+ if (eq $input "r") {
+ run
+ } elif (eq $input "c") {
+ clean
+ }
+ }
+}
+
+fn tailwind_watch {
+ clear
+ tailwindcss -i input.css -o ./static/styles.css --watch
}
var input
while (not-eq $input "q") {
clear
+ echo "[D]ev Deploy, [T]ailwind Watch, [Q]uit"
- echo "[R]un, [B]uild, [Q]uit"
-
- set input = (read-line)
+ set input = (sh -c 'read -n1 && echo $REPLY' | take 1)
- if (eq $input "r") {
- run
- } elif (eq $input "b") {
- build
+ if (eq $input "d") {
+ docker_menu
+ } elif (eq $input "t") {
+ tailwind_watch
}
}
A docker-compose.yaml => docker-compose.yaml +45 -0
@@ 0,0 1,45 @@
+version: "3.8"
+
+networks:
+ internal:
+ external: false
+
+volumes:
+ tixedb_data:
+ driver: local
+
+services:
+ tixedb:
+ image: postgres:15-alpine
+ container_name: tixedb
+ restart: always
+ networks:
+ - internal
+ volumes:
+ - tixedb_data:/var/lib/postgresql/data
+ environment:
+ POSTGRES_USER: tixe
+ POSTGRES_PASSWORD: tixe
+ POSTGRES_DB: tixe
+
+ tixe:
+ build: .
+ image: tixe
+ container_name: tixe
+ restart: always
+ networks:
+ - internal
+ ports:
+ - 8080:8080
+ environment:
+ TZ: Europe/Helsinki
+ GIN_MODE: release # or "debug" for debug logs
+ TIXE_PSQL_HOST: tixedb
+ TIXE_PSQL_PORT: 5432
+ TIXE_PSQL_USER: tixe
+ TIXE_PSQL_PASSWORD: tixe
+ TIXE_PSQL_DB: tixe
+ TIXE_OIDC_GITHUB: false
+ TIXE_OIDC_CUSTOM: true
+ depends_on:
+ - tixedb