Setup Docker building.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
*.db
|
||||
*.sqlite
|
||||
shagram.db
|
||||
project_context.txt
|
||||
.vscode
|
||||
.idea
|
||||
*.log
|
||||
.env
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
+20
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user