shynet/Dockerfile

52 lines
2.0 KiB
Docker
Raw Normal View History

2022-01-01 02:26:57 +08:00
FROM python:alpine3.14
2020-04-14 22:55:01 +08:00
2020-05-03 22:41:14 +08:00
# Getting things ready
2020-04-14 22:55:01 +08:00
WORKDIR /usr/src/shynet
2020-05-03 22:41:14 +08:00
# Install dependencies & configure machine
ARG GF_UID="500"
ARG GF_GID="500"
RUN apk update && \
apk add --no-cache gettext bash npm postgresql-libs && \
test "$(arch)" != "x86_64" && apk add libffi-dev rust cargo || echo "amd64 build, skipping Rust installation"
2021-07-20 12:51:13 +08:00
# libffi-dev and rust are used for the cryptography package,
# which we indirectly rely on. Necessary for aarch64 support.
# Collect GeoIP Database
RUN apk add --no-cache curl && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=kKG1ebhL3iWVd0iv&suffix=tar.gz" | tar -xvz -C /tmp && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=kKG1ebhL3iWVd0iv&suffix=tar.gz" | tar -xvz -C /tmp && \
mv /tmp/GeoLite2*/*.mmdb /etc && \
apk --purge del curl
2021-07-20 12:51:13 +08:00
# Move dependency files
COPY poetry.lock pyproject.toml ./
COPY package.json package-lock.json ../
# Django expects node_modules to be in its parent directory.
# Install more dependencies and cleanup build dependencies afterwards
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev libressl-dev libffi-dev && \
2020-06-28 10:58:49 +08:00
npm i -P --prefix .. && \
pip install poetry==1.2.2 && \
poetry config virtualenvs.create false && \
poetry run pip install "Cython<3.0" "pyyaml==5.4.1" --no-build-isolation && \
poetry install --no-dev --no-interaction --no-ansi && \
apk --purge del .build-deps
# Setup user group
RUN addgroup --system -g $GF_GID appgroup && \
adduser appuser --system --uid $GF_UID -G appgroup && \
mkdir -p /var/local/shynet/db/ && \
chown -R appuser:appgroup /var/local/shynet
2020-04-14 22:55:01 +08:00
2020-05-03 22:41:14 +08:00
# Install Shynet
COPY shynet .
RUN python manage.py collectstatic --noinput && \
python manage.py compilemessages
# Launch
2020-04-14 22:55:01 +08:00
USER appuser
EXPOSE 8080
HEALTHCHECK CMD bash -c 'wget -o /dev/null -O /dev/null --header "Host: ${ALLOWED_HOSTS%%,*}" "http://127.0.0.1:${PORT:-8080}/healthz/?format=json"'
CMD [ "./entrypoint.sh" ]