Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Added Dockerfile #460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added Dockerfile #460

wants to merge 1 commit into from

Conversation

boivie
Copy link

@boivie boivie commented Sep 30, 2017

It's written to generate a small image - around 16 MB.

Fixes #372

It's written to generate a small image - around 16 MB.

Fixes bitly#372
@ploxiln
Copy link
Contributor

ploxiln commented Sep 30, 2017

Probably worth mentioning: I think this requires the very latest version of docker aka moby 17.05.0-ce

@ploxiln
Copy link
Contributor

ploxiln commented Sep 30, 2017

hmm I take that back, it seems that's just when docker stopped tagging releases in the public github repo

@boivie
Copy link
Author

boivie commented Oct 1, 2017

Yes, it's a new feature of Docker 17.05. That's why I recommend building it at Docker Cloud, which supports it.

@jehiah jehiah added this to the v2.3 milestone Oct 23, 2017
@yacut
Copy link

yacut commented Dec 6, 2017

You cloud use scratch image to reduce image size to 30% :)
Stratch: 11.6MB
Alpine: 16.1MB

FROM golang:1.9 AS builder
WORKDIR /go/src/github.com/bitly/oauth2_proxy
COPY . .
RUN go get -d -v; \
    CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo . ; \
    curl -o ca-certificates.crt https://curl.haxx.se/ca/cacert.pem;

FROM scratch
COPY --from=builder /go/src/github.com/bitly/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
COPY --from=builder /go/src/github.com/bitly/oauth2_proxy/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

ENTRYPOINT ["/bin/oauth2_proxy"]

@jacobalberty
Copy link

Using boivie's dockerfile now works great hope to see official images soon.

Couldn't get the from scratch one working, kept giving errors relating to the cert chain. just a little tip though you don't need to curl the cert file as you can just use

ADD https://curl.haxx.se/ca/cacert.perm /etc/ssl/certs/ca-certificates.crt

to pull it instead.

@jacobalberty
Copy link

Oh and one other suggested change. Add a .dockerignore file to the root that contains at least

Dockerfile

This will ensure editing your Dockerfile doesn't immediately invalidate virtually the entire build cache so if you're testing things using a local built Dockerfile you can take advantage of the build cache to decide whether or not the whole thing needs to be rebuilt.

RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/bitly/oauth2_proxy/oauth2_proxy .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "USER nobody" so we don't run as root

@adrianchifor
Copy link

Any update?

@ploxiln ploxiln mentioned this pull request May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

7 participants