12345678910111213141516171819202122232425262728293031323334 |
- FROM golang:1.21-alpine AS builder
- WORKDIR /app
- # Copy go mod and sum files
- COPY go.mod go.sum ./
- RUN go mod download
- # Copy the source code
- COPY . .
- # Build the application
- RUN CGO_ENABLED=1 GOOS=linux go build -o filecloud ./cmd/filecloud.go
- # Create necessary directories
- RUN mkdir -p public data conf
- # Final stage
- FROM alpine:latest
- WORKDIR /app
- # Copy the binary and necessary directories from builder
- COPY --from=builder /app/filecloud .
- COPY --from=builder /app/public ./public
- COPY --from=builder /app/data ./data
- COPY --from=builder /app/conf ./conf
- # Install SQLite
- RUN apk add --no-cache sqlite
- EXPOSE 8080
- CMD ["./filecloud"]
|