Setup Docker building.

This commit is contained in:
emil28092005
2026-01-14 04:19:00 +03:00
parent 7df170e37d
commit e883aac2e8
4 changed files with 48 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
.git
.gitignore
README.md
*.db
*.sqlite
shagram.db
project_context.txt
.vscode
.idea
*.log
.env
docker-compose.yml
Dockerfile
+20
View File
@@ -0,0 +1,20 @@
FROM golang:1.25.5-alpine AS builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o shagram ./cmd/server
FROM alpine:latest
RUN apk --no-cache add ca-certificates sqlite-libs
WORKDIR /app
COPY --from=builder /app/shagram .
COPY static ./static
COPY migrations ./migrations
RUN mkdir -p /app/data
EXPOSE 8080
CMD ["./shagram"]
+1 -1
View File
@@ -12,7 +12,7 @@ import (
)
func main() {
database, err := db.NewDB("shagram.db")
database, err := db.NewDB("/app/data/shagram.db")
if err != nil {
log.Fatal(err)
}
+14
View File
@@ -0,0 +1,14 @@
version: '3.8'
services:
shagram:
build: .
ports:
- "8080:8080"
volumes:
- ./data:/app/data
- ./static:/app/static
- ./migrations:/app/migrations
environment:
- DATABASE_PATH=/app/shagram.db
container_name: shagram-app