Prepare backend Docker deployment for Hugging Face Spaces
Browse files- .dockerignore +9 -0
- Dockerfile +29 -0
- backend/main.go +1 -1
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
.gitignore
|
| 3 |
+
frontend
|
| 4 |
+
backend/.env
|
| 5 |
+
backend/creepurl.db
|
| 6 |
+
backend/creepurl.db-shm
|
| 7 |
+
backend/creepurl.db-wal
|
| 8 |
+
**/node_modules
|
| 9 |
+
**/dist
|
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM golang:1.21-alpine AS builder
|
| 2 |
+
|
| 3 |
+
WORKDIR /src
|
| 4 |
+
|
| 5 |
+
COPY backend/go.mod backend/go.sum ./backend/
|
| 6 |
+
WORKDIR /src/backend
|
| 7 |
+
RUN go mod download
|
| 8 |
+
|
| 9 |
+
COPY backend/ ./
|
| 10 |
+
|
| 11 |
+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /out/creepurl main.go
|
| 12 |
+
|
| 13 |
+
FROM alpine:3.20
|
| 14 |
+
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
RUN adduser -D -u 10001 appuser && chown appuser:appuser /app
|
| 18 |
+
|
| 19 |
+
COPY --from=builder --chown=appuser:appuser /out/creepurl ./creepurl
|
| 20 |
+
COPY --chown=appuser:appuser backend/database ./database
|
| 21 |
+
|
| 22 |
+
ENV PORT=7860
|
| 23 |
+
ENV DB_PATH=./creepurl.db
|
| 24 |
+
|
| 25 |
+
EXPOSE 7860
|
| 26 |
+
|
| 27 |
+
USER appuser
|
| 28 |
+
|
| 29 |
+
CMD ["./creepurl"]
|
backend/main.go
CHANGED
|
@@ -44,7 +44,7 @@ func main() {
|
|
| 44 |
|
| 45 |
port := os.Getenv("PORT")
|
| 46 |
if port == "" {
|
| 47 |
-
port = "
|
| 48 |
}
|
| 49 |
|
| 50 |
log.Printf("CreepURL API starting on port %s [%s]", port, cfg.Environment)
|
|
|
|
| 44 |
|
| 45 |
port := os.Getenv("PORT")
|
| 46 |
if port == "" {
|
| 47 |
+
port = "7860"
|
| 48 |
}
|
| 49 |
|
| 50 |
log.Printf("CreepURL API starting on port %s [%s]", port, cfg.Environment)
|