Skip to content

Commit

Permalink
Fixed the Dockerfile to resolve exec /usr/local/bin/app: exec format …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
shambhand committed Oct 17, 2024
1 parent 2233fda commit 78fde55
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ RUN go mod download
COPY . .

# Build the Go application statically to ensure there are no dependencies on the system
RUN go build -o /go/bin/app ./src/main.go
# RUN go build -o /go/bin/app ./src/main.go
RUN GOOS=linux GOARCH=arm64 go build -o /go/bin/app ./src/main.go

# Install CA certificates
RUN apk --no-cache add ca-certificates

# Step 2: Create a minimal, secure runtime image using a scratch image
FROM scratch
FROM alpine:latest

# Copy the compiled Go binary from the builder stage
COPY --from=builder /go/bin/app /usr/local/bin/app

# Use a non-root user to run the application
RUN adduser -D -u 1001 appuser
USER 1001

# Set the entry point to the compiled Go binary
Expand Down

0 comments on commit 78fde55

Please sign in to comment.