Optimize docker image (merges #21)
This commit is contained in:
commit
446d672004
44
Dockerfile
44
Dockerfile
@ -1,33 +1,33 @@
|
|||||||
FROM python:3
|
FROM python:3-alpine
|
||||||
|
|
||||||
WORKDIR /usr/src/shynet
|
WORKDIR /usr/src/shynet
|
||||||
|
COPY Pipfile.lock Pipfile ./
|
||||||
RUN apt update
|
|
||||||
RUN apt install -y gettext
|
|
||||||
|
|
||||||
# URL from https://github.com/shlinkio/shlink/issues/596 :)
|
|
||||||
RUN curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp
|
|
||||||
RUN curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp
|
|
||||||
RUN mv /tmp/GeoLite2*/*.mmdb /etc
|
|
||||||
|
|
||||||
RUN pip install pipenv
|
|
||||||
COPY Pipfile.lock ./
|
|
||||||
COPY Pipfile ./
|
|
||||||
RUN pipenv install --system --deploy
|
|
||||||
|
|
||||||
COPY shynet .
|
COPY shynet .
|
||||||
RUN python manage.py collectstatic --noinput
|
|
||||||
RUN python manage.py compilemessages
|
RUN apk update && \
|
||||||
|
apk add gettext curl bash && \
|
||||||
|
# URL from https://github.com/shlinkio/shlink/issues/596 :)
|
||||||
|
curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp && \
|
||||||
|
curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp && \
|
||||||
|
mv /tmp/GeoLite2*/*.mmdb /etc && \
|
||||||
|
apk del curl && \
|
||||||
|
apk add --no-cache postgresql-libs && \
|
||||||
|
apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
|
||||||
|
pip install pipenv && \
|
||||||
|
pipenv install --system --deploy && \
|
||||||
|
apk --purge del .build-deps && \
|
||||||
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
|
rm /var/cache/apk/*
|
||||||
|
|
||||||
ARG GF_UID="500"
|
ARG GF_UID="500"
|
||||||
ARG GF_GID="500"
|
ARG GF_GID="500"
|
||||||
|
|
||||||
# add group & user
|
# add group & user
|
||||||
RUN groupadd -r -g $GF_GID appgroup && \
|
RUN python manage.py collectstatic --noinput && \
|
||||||
useradd appuser -r -u $GF_UID -g appgroup
|
python manage.py compilemessages && \
|
||||||
|
addgroup --system -g $GF_GID appgroup && \
|
||||||
|
adduser appuser --system --uid $GF_UID -G appgroup
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT [ "./entrypoint.sh" ]
|
||||||
ENTRYPOINT [ "./entrypoint.sh" ]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user