Dockerfile 649 B

12345678910111213141516171819202122232425262728293031323334
  1. FROM golang:1.21-alpine AS builder
  2. WORKDIR /app
  3. # Copy go mod and sum files
  4. COPY go.mod go.sum ./
  5. RUN go mod download
  6. # Copy the source code
  7. COPY . .
  8. # Build the application
  9. RUN CGO_ENABLED=1 GOOS=linux go build -o filecloud ./cmd/filecloud.go
  10. # Create necessary directories
  11. RUN mkdir -p public data conf
  12. # Final stage
  13. FROM alpine:latest
  14. WORKDIR /app
  15. # Copy the binary and necessary directories from builder
  16. COPY --from=builder /app/filecloud .
  17. COPY --from=builder /app/public ./public
  18. COPY --from=builder /app/data ./data
  19. COPY --from=builder /app/conf ./conf
  20. # Install SQLite
  21. RUN apk add --no-cache sqlite
  22. EXPOSE 8080
  23. CMD ["./filecloud"]