Use multi stage dockerfile for building

This also adds a docker-compose.yml for easy running and rebuilding

Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
Felix Bartels 2020-10-31 19:09:28 -04:00
parent e93fc79f23
commit eacc0094aa
4 changed files with 32 additions and 14 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.dockerignore
.git
Dockerfile

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM golang:1.15-alpine3.12 as builder
WORKDIR /build
RUN apk add git
RUN go get github.com/GeertJohan/go.rice/rice
COPY go.* ./
RUN go mod download
COPY . .
RUN rice embed-go
RUN CGO_ENABLED=0 go build
FROM scratch
EXPOSE 80 443
COPY --from=builder /build/boringproxy /
ENTRYPOINT ["/boringproxy"]
CMD ["server"]

8
docker-compose.yml Normal file
View File

@ -0,0 +1,8 @@
version: '3.5'
services:
boringproxy:
build: ./
image: boringproxy
ports:
- "80:80"
- "443:443"

View File

@ -1,14 +0,0 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl git
RUN git clone https://github.com/boringproxy/boringproxy
WORKDIR boringproxy
RUN ./install_go.sh
ENV PATH="${PATH}:/usr/local/go/bin"
ENV PATH="${PATH}:/root/go/bin"
RUN go get github.com/GeertJohan/go.rice/rice
RUN rice embed-go
RUN go build
CMD ./boringproxy server