Skip to content

Instantly share code, notes, and snippets.

@michaelboke
Last active June 26, 2024 14:46
Show Gist options
  • Save michaelboke/564bf96f7331f35f1716b59984befc50 to your computer and use it in GitHub Desktop.
Save michaelboke/564bf96f7331f35f1716b59984befc50 to your computer and use it in GitHub Desktop.
Docker scratch x509 fix
FROM golang:alpine as builder
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
RUN update-ca-certificates
ADD main.go /app/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o app .
FROM scratch
COPY --from=builder /app/app .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
CMD ["./app"]
package main
import (
"net/http"
"fmt"
)
func main(){
_, err := http.Get("https://www.google.com")
if err!= nil {
panic(err)
}
fmt.Println("success")
}
@bdw617
Copy link

bdw617 commented Nov 10, 2022

this is an awesome example and fixed my problem with aws-sdk-go. I really appreciate the time you spent building such a simple example.

@ezynda3
Copy link

ezynda3 commented Jan 11, 2023

This just saved my bacon. Thanks!

@marlongerson
Copy link

Thank you good sir.

@xandreafonso
Copy link

Thanks!!

@holynuts
Copy link

Thanks very much, that solved my problem.

@Barkwi
Copy link

Barkwi commented Jun 26, 2024

Thanks this helped with my problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment