Dockerfiles

This commit is contained in:
Brieuc Dubois 2024-01-03 18:13:54 +01:00
parent bf6873d261
commit 454fe9b4bc
6 changed files with 68 additions and 1 deletions

4
backend/.dockerignore Normal file
View File

@ -0,0 +1,4 @@
*.sqlite
Dockerfile
docker-compose.yaml
.dockerignore

20
backend/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM golang:1.21.5 as backend-builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -o main .
# FROM alpine:latest
FROM debian:stable-slim
VOLUME /data
WORKDIR /app
COPY --from=backend-builder /app/main .
EXPOSE 3000
ENV DB_PATH=/data/db.sqlite
CMD ["./main"]

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"os"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
@ -14,8 +15,13 @@ import (
func main() {
driver := "sqlite3"
connStr := "db.sqlite"
port := "3000"
connStr := os.Getenv("DB_PATH")
if connStr == "" {
connStr = "db.sqlite"
}
origins := "*"
if err := db.InitDB(driver, connStr); err != nil {

10
frontend/.dockerignore Normal file
View File

@ -0,0 +1,10 @@
node_modules
.eslint*
.prettier*
.git*
Dockerfile
docker-compose.yaml
public
.svelte-kot
build
.dockerignore

17
frontend/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:20 as frontend-builder
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
FROM node:20-alpine
# COPY --from=frontend-builder /app/public /usr/share/nginx/html
COPY --from=frontend-builder /app .
EXPOSE 4173
CMD ["npm", "run", "preview", "--", "--port", "4173", "--host", "0.0.0.0"]

View File

@ -15,6 +15,7 @@
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
@ -835,6 +836,15 @@
"@sveltejs/kit": "^2.0.0"
}
},
"node_modules/@sveltejs/adapter-static": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.1.tgz",
"integrity": "sha512-6lMvf7xYEJ+oGeR5L8DFJJrowkefTK6ZgA4JiMqoClMkKq0s6yvsd3FZfCFvX1fQ0tpCD7fkuRVHsnUVgsHyNg==",
"dev": true,
"peerDependencies": {
"@sveltejs/kit": "^2.0.0"
}
},
"node_modules/@sveltejs/kit": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.0.6.tgz",