mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-03-01 03:31:32 +00:00
Merge remote-tracking branch 'chrisss404/master'
This commit is contained in:
commit
6880657367
@ -1,34 +1,90 @@
|
|||||||
FROM debian:stretch-slim
|
FROM alpine:3.10 AS builder
|
||||||
LABEL maintainer="k@ndk.name"
|
LABEL maintainer="k@ndk.name"
|
||||||
|
|
||||||
ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
|
ARG BUILD_DEPENDENCIES="build-base \
|
||||||
|
libffi-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
mariadb-connector-c-dev \
|
||||||
|
openldap-dev \
|
||||||
|
py3-pip \
|
||||||
|
python3-dev \
|
||||||
|
xmlsec-dev \
|
||||||
|
yarn"
|
||||||
|
|
||||||
RUN apt-get update -y \
|
ENV LC_ALL=en_US.UTF-8 \
|
||||||
&& apt-get install -y --no-install-recommends apt-transport-https locales locales-all python3-pip python3-setuptools python3-dev curl libsasl2-dev libldap2-dev libssl-dev libxml2-dev libxslt1-dev libxmlsec1-dev libffi-dev build-essential libmariadb-dev-compat \
|
LANG=en_US.UTF-8 \
|
||||||
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
|
LANGUAGE=en_US.UTF-8 \
|
||||||
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
FLASK_APP=/build/powerdnsadmin/__init__.py
|
||||||
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
|
|
||||||
&& apt-get update -y \
|
# Get dependencies
|
||||||
&& apt-get install -y nodejs yarn \
|
RUN apk add --no-cache ${BUILD_DEPENDENCIES} && \
|
||||||
&& apt-get clean -y \
|
ln -s /usr/bin/pip3 /usr/bin/pip
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
# We copy just the requirements.txt first to leverage Docker cache
|
# We copy just the requirements.txt first to leverage Docker cache
|
||||||
COPY ./requirements.txt /app/requirements.txt
|
COPY ./requirements.txt /build/requirements.txt
|
||||||
|
|
||||||
|
# Get application dependencies
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Add sources
|
||||||
|
COPY . /build
|
||||||
|
|
||||||
|
# Prepare assets
|
||||||
|
RUN yarn install --pure-lockfile --production && \
|
||||||
|
yarn cache clean && \
|
||||||
|
sed -i -e "s|'cssmin','cssrewrite'|'cssmin'|g" /build/powerdnsadmin/assets.py && \
|
||||||
|
flask assets build
|
||||||
|
|
||||||
|
RUN mv /build/powerdnsadmin/static /tmp/static && \
|
||||||
|
mkdir /build/powerdnsadmin/static && \
|
||||||
|
cp -r /tmp/static/generated /build/powerdnsadmin/static && \
|
||||||
|
find /tmp/static/node_modules -name 'fonts' -exec cp -r {} /build/powerdnsadmin/static \; && \
|
||||||
|
find /tmp/static/node_modules/icheck/skins/square -name '*.png' -exec cp {} /build/powerdnsadmin/static/generated \;
|
||||||
|
|
||||||
|
RUN { \
|
||||||
|
echo "from flask_assets import Environment"; \
|
||||||
|
echo "assets = Environment()"; \
|
||||||
|
echo "assets.register('js_login', 'generated/login.js')"; \
|
||||||
|
echo "assets.register('js_validation', 'generated/validation.js')"; \
|
||||||
|
echo "assets.register('css_login', 'generated/login.css')"; \
|
||||||
|
echo "assets.register('js_main', 'generated/main.js')"; \
|
||||||
|
echo "assets.register('css_main', 'generated/main.css')"; \
|
||||||
|
} > /build/powerdnsadmin/assets.py
|
||||||
|
|
||||||
|
# Move application
|
||||||
|
RUN mkdir -p /app && \
|
||||||
|
cp -r /build/migrations/ /build/powerdnsadmin/ /build/run.py /app && \
|
||||||
|
mkdir -p /app/configs && \
|
||||||
|
cp -r /build/configs/docker_config.py /app/configs
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
RUN pip install pip-autoremove && \
|
||||||
|
pip-autoremove cssmin -y && \
|
||||||
|
pip-autoremove jsmin -y && \
|
||||||
|
pip-autoremove pytest -y && \
|
||||||
|
pip uninstall -y pip-autoremove && \
|
||||||
|
apk del ${BUILD_DEPENDENCIES}
|
||||||
|
|
||||||
|
|
||||||
|
# Build image
|
||||||
|
FROM alpine:3.10
|
||||||
|
|
||||||
|
ENV FLASK_APP=/app/powerdnsadmin/__init__.py
|
||||||
|
|
||||||
|
RUN apk add --no-cache mariadb-connector-c postgresql-client py3-gunicorn py3-psycopg2 xmlsec && \
|
||||||
|
addgroup -S pda && \
|
||||||
|
adduser -S -D -G pda pda
|
||||||
|
|
||||||
|
COPY --from=builder /usr/bin/flask /usr/bin/
|
||||||
|
COPY --from=builder /usr/lib/python3.7/site-packages /usr/lib/python3.7/site-packages/
|
||||||
|
COPY --from=builder --chown=pda:pda /app /app/
|
||||||
|
COPY ./docker/entrypoint.sh /usr/bin/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip3 install --upgrade pip
|
|
||||||
RUN pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
COPY ./docker/entrypoint.sh /usr/local/bin/
|
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
||||||
|
|
||||||
ENV FLASK_APP=powerdnsadmin/__init__.py
|
|
||||||
RUN yarn install --pure-lockfile --production \
|
|
||||||
&& yarn cache clean \
|
|
||||||
&& flask assets build
|
|
||||||
|
|
||||||
EXPOSE 80/tcp
|
EXPOSE 80/tcp
|
||||||
|
HEALTHCHECK CMD ["wget","--output-document=-","--quiet","--tries=1","http://127.0.0.1/"]
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
CMD ["gunicorn","powerdnsadmin:create_app()"]
|
CMD ["gunicorn","powerdnsadmin:create_app()","--user","pda","--group","pda"]
|
||||||
|
4
docker/entrypoint.sh
Normal file → Executable file
4
docker/entrypoint.sh
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -Eeuo pipefail
|
set -euo pipefail
|
||||||
cd /app
|
cd /app
|
||||||
|
|
||||||
GUNICORN_TIMEOUT="${GUINCORN_TIMEOUT:-120}"
|
GUNICORN_TIMEOUT="${GUINCORN_TIMEOUT:-120}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user