make Docker image smaller and more reusable

pull/504/head
Emil Lerch 4 years ago
parent f87a825d8b
commit 1c2a03b50a
No known key found for this signature in database
GPG Key ID: A7B62D657EF764F8

@ -1,54 +1,87 @@
FROM ubuntu:18.04 # Build stage
FROM golang:1-alpine as builder
RUN apt-get update && \
apt-get install -y curl \
git \
python \
python-pip \
python-dev \
autoconf \
libtool \
gawk
RUN curl -O https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
RUN tar xvf go1.10.3.linux-amd64.tar.gz
WORKDIR /app WORKDIR /app
COPY ./bin /app/bin COPY ./share/we-lang/we-lang.go /app
COPY ./lib /app/lib
COPY ./share /app/share RUN apk add --no-cache git
COPY ./requirements.txt /app
COPY ./src/we-lang/we-lang.go /app
# There are several files that must be fetched/created manually
# before building the image
COPY ./.wegorc /root
COPY ./.ip2location.key /root
COPY ./airports.dat /app
COPY ./GeoLite2-City.mmdb /app
RUN export PATH=$PATH:/go/bin && \ RUN true && \
go get -u github.com/mattn/go-colorable && \ go get -u github.com/mattn/go-colorable && \
go get -u github.com/klauspost/lctime && \ go get -u github.com/klauspost/lctime && \
go get -u github.com/mattn/go-runewidth && \ go get -u github.com/mattn/go-runewidth && \
export GOBIN="/root/go/bin" && \ CGO_ENABLED=0 go build /app/we-lang.go
go install /app/we-lang.go # Results in /app/we-lang
# FROM ubuntu:18.04
# RUN apt-get update && \
# apt-get install -y curl \
# git \
# python \
# python-pip \
# python-dev \
# autoconf \
# libtool \
# gawk
FROM alpine:3
WORKDIR /app
COPY ./requirements.txt /app
ENV LLVM_CONFIG=/usr/bin/llvm9-config
RUN apk add --no-cache \
python3 \
py3-pip \
py3-scipy \
py3-wheel \
py3-gevent \
zlib \
jpeg \
gcc \
g++ \
llvm9 \
make \
autoconf \
automake \
libtool \
supervisor \
zlib-dev \
jpeg-dev \
llvm9-dev \
py3-numpy-dev \
python3-dev && \
mkdir -p /app/cache && \
mkdir -p /var/log/supervisor && \
mkdir -p /etc/supervisor/conf.d && \
chmod -R o+rw /var/log/supervisor && \
chmod -R o+rw /var/run && \
pip install -r requirements.txt && \
apk del --no-cache -r gcc g++ make autoconf automake libtool zlib-dev jpeg-dev llvm9-dev
COPY --from=builder /app/we-lang /app/bin/we-lang
COPY ./bin /app/bin
COPY ./lib /app/lib
COPY ./share /app/share
RUN pip install -r requirements.txt # These files should be mounted by the user at runtime:
# /root/.wegorc
# /root/.ip2location.key (optional)
# /app/airports.dat
# /app/GeoLite2-City.mmdb
RUN mkdir /app/cache
RUN mkdir -p /var/log/supervisor && \
mkdir -p /etc/supervisor/conf.d
RUN chmod -R o+rw /var/log/supervisor && \
chmod -R o+rw /var/run
COPY share/docker/supervisord.conf /etc/supervisor/supervisord.conf COPY share/docker/supervisord.conf /etc/supervisor/supervisord.conf
ENV WTTR_MYDIR="/app" ENV WTTR_MYDIR="/app"
ENV WTTR_GEOLITE="/app/GeoLite2-City.mmdb" ENV WTTR_GEOLITE="/app/GeoLite2-City.mmdb"
ENV WTTR_WEGO="/root/go/bin/we-lang" ENV WTTR_WEGO="/app/bin/we-lang"
ENV WTTR_LISTEN_HOST="0.0.0.0" ENV WTTR_LISTEN_HOST="0.0.0.0"
ENV WTTR_LISTEN_PORT="8002" ENV WTTR_LISTEN_PORT="8002"
EXPOSE 8002 EXPOSE 8002
CMD ["/usr/local/bin/supervisord"] CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

@ -4,19 +4,19 @@ logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid pidfile=/var/run/supervisord.pid
[program:srv] [program:srv]
command=python /app/bin/srv.py command=python3 /app/bin/srv.py
stderr_logfile=/var/log/supervisor/srv-stderr.log stderr_logfile=/var/log/supervisor/srv-stderr.log
stdout_logfile=/var/log/supervisor/srv-stdout.log stdout_logfile=/var/log/supervisor/srv-stdout.log
[program:proxy] [program:proxy]
command=python /app/bin/proxy.py command=python3 /app/bin/proxy.py
stderr_logfile=/var/log/supervisor/proxy-stderr.log stderr_logfile=/var/log/supervisor/proxy-stderr.log
stdout_logfile=/var/log/supervisor/proxy-stdout.log stdout_logfile=/var/log/supervisor/proxy-stdout.log
[program:geoproxy] [program:geoproxy]
command=python /app/bin/geo-proxy.py command=python3 /app/bin/geo-proxy.py
stderr_logfile=/var/log/supervisor/geoproxy-stderr.log stderr_logfile=/var/log/supervisor/geoproxy-stderr.log
stdout_logfile=/var/log/supervisor/geoproxy-stdout.log stdout_logfile=/var/log/supervisor/geoproxy-stdout.log
[include] [include]
files=/etc/supervisor/conf.d/*.conf files=/etc/supervisor/conf.d/*.conf

Loading…
Cancel
Save