bro, help gen a dockerfile for golang web app that uses sqlite 3 and gorm
- User
bro, help gen a dockerfile for golang web app that uses sqlite 3 and gorm
- Assistant
Sure, here's a basic Dockerfile for a Go web application that uses SQLite3 and GORM. This Dockerfile assumes that your Go application is located in a directory named
appand that you have already vendored your dependencies using a tool likegovendor,dep, orgo mod.# Use the official Golang image. # This is based on Alpine Linux with the Go toolchain installed. FROM golang:1.16-alpine AS builder # Set the working directory to the app directory. WORKDIR /app # Copy the current directory (i.e., your Go application) into the container. COPY . . # Install the SQLite3 driver for Go. RUN apk add --no-cache sqlite sqlite-dev && \ go get -u github.com/mattn/go-sqlite3 # Build the Go application. RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . # Use the official Alpine Linux image. # This is much smaller than the Golang image, and we don't need the Go toolchain # in this image because we're just going to run the compiled binary. FROM alpine:3.13 # Copy the binary from the builder stage. COPY --from=builder /app/main /app/main # Run the binary when the container starts. CMD ["/app/main"]
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.