Redo Dockerfile
This commit is contained in:
parent
614e438eed
commit
86a96b8bc7
50
Dockerfile
50
Dockerfile
|
@ -1,47 +1,19 @@
|
|||
FROM ubuntu:16.04 as compy-builder
|
||||
MAINTAINER Barna Csorogi <barnacs@justletit.be>
|
||||
FROM golang:1.12-alpine as builder
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
g++ \
|
||||
git \
|
||||
libjpeg8-dev
|
||||
WORKDIR /root/go/src/github.com/barnacs/compy/
|
||||
|
||||
RUN mkdir -p /usr/local/ && \
|
||||
curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \
|
||||
tar xf go1.9.linux-amd64.tar.gz -C /usr/local
|
||||
COPY . .
|
||||
|
||||
RUN mkdir -p /root/go/src/github.com/barnacs/compy/
|
||||
COPY . /root/go/src/github.com/barnacs/compy/
|
||||
WORKDIR /root/go/src/github.com/barnacs/compy
|
||||
RUN /usr/local/go/bin/go get -d -v ./...
|
||||
RUN /usr/local/go/bin/go build -v
|
||||
RUN apk add --no-cache --no-progress git g++ libjpeg-turbo-dev
|
||||
RUN go get -d -v ./...
|
||||
RUN go build -ldflags='-extldflags "-static" -s -w' -o /go/bin/compy
|
||||
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Barna Csorogi <barnacs@justletit.be>
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libjpeg8 \
|
||||
openssl \
|
||||
ssl-cert && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
FROM scratch
|
||||
|
||||
WORKDIR /opt/compy
|
||||
COPY \
|
||||
--from=compy-builder \
|
||||
/root/go/src/github.com/barnacs/compy/compy \
|
||||
/root/go/src/github.com/barnacs/compy/docker.sh \
|
||||
/opt/compy/
|
||||
LABEL maintainer="Sandro Jäckel <sandro.jaeckel@gmail.com>"
|
||||
|
||||
# TODO: configure HTTP BASIC authentication
|
||||
# TODO: user-provided certificates
|
||||
ENV \
|
||||
CERTIFICATE_DOMAIN="localhost"
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /go/bin/compy compy
|
||||
|
||||
EXPOSE 9999
|
||||
ENTRYPOINT ["./docker.sh"]
|
||||
ENTRYPOINT ["./compy"]
|
||||
|
|
16
README.md
16
README.md
|
@ -101,11 +101,19 @@ For compression, transcoding and minification options, see `compy --help`
|
|||
Docker Usage
|
||||
------------
|
||||
|
||||
Andrew Gaul publishes unofficial Docker images at
|
||||
https://hub.docker.com/r/andrewgaul/compy/ . You can configure via:
|
||||
|
||||
To build the docker image just run in the git repository
|
||||
```
|
||||
sudo docker run --name=compy --env CERTIFICATE_DOMAIN=example.com --publish 9999:9999 andrewgaul/compy
|
||||
docker build -t compy .
|
||||
```
|
||||
|
||||
To run the container
|
||||
```
|
||||
docker run -d --name compy -p 9999:9999 compy
|
||||
```
|
||||
|
||||
To run the container with https enabled. You need to generate the certificates on your host and provide the path to docker.
|
||||
```
|
||||
docker run -d --name compy -p 9999:9999 -v $PWD/cert.crt:/cert.crt -v $PWD/cert.key:/cert.key -v $PWD/ca.crt:/ca.crt -v $PWD/ca.key:/ca.key compy -cert cert.crt -key cert.key -ca ca.crt -cakey ca.key
|
||||
```
|
||||
|
||||
References
|
||||
|
|
15
docker.sh
15
docker.sh
|
@ -1,15 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
openssl req -x509 -newkey rsa:2048 -nodes -keyout cert.key -out cert.crt -days 3650 -subj "/CN=${CERTIFICATE_DOMAIN}"
|
||||
openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 3650 -subj "/CN=${CERTIFICATE_DOMAIN}"
|
||||
|
||||
echo 'Generated server certificate:'
|
||||
cat cert.crt
|
||||
echo
|
||||
echo 'Generated CA certificate:'
|
||||
cat ca.crt
|
||||
|
||||
exec ./compy \
|
||||
-cert cert.crt -key cert.key \
|
||||
-ca ca.crt -cakey ca.key \
|
||||
:9999
|
Loading…
Reference in New Issue