Skip to content

Commit

Permalink
Compile Docker image without CGO
Browse files Browse the repository at this point in the history
As it required by go-sqlite3 dependency:
```
pacoloco    | prefetch.go:67: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
pacoloco exited with code 1
```

It switches the resulting docker image from a scratch base to alpine, which allows libraries that require CGO such as go-sqlite3 to work.

Closes anatol#33
  • Loading branch information
ilya-zlobintsev authored and anatol committed Nov 10, 2021
1 parent 01baa22 commit bd677a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM golang:latest as build
FROM golang:alpine3.13 as build

RUN apk add gcc libc-dev

WORKDIR /build

COPY . .

RUN CGO_ENABLED=0 go build -ldflags="-s -w"
RUN go build -ldflags="-s -w"

FROM scratch
FROM alpine:3.13

WORKDIR /pacoloco

Expand Down

0 comments on commit bd677a1

Please sign in to comment.