-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from SteveKueng/docker
Docker
- Loading branch information
Showing
1,654 changed files
with
6,792 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM python:3.11-slim | ||
|
||
# set work directory | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# ------ update and install software | ||
# update | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y gcc default-libmysqlclient-dev python3-dev \ | ||
libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev \ | ||
build-essential libssl-dev libffi-dev libjpeg-dev \ | ||
libpq-dev liblcms2-dev libblas-dev libatlas-base-dev pkg-config curl unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# ------- | ||
|
||
# install dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
|
||
# create dirs | ||
RUN mkdir /munkirepo | ||
RUN mkdir /munkitools | ||
|
||
# download munkitools | ||
RUN curl -Lk -o /tmp/munkitools.zip `curl --silent https://api.github.com/repos/munki/munki/releases/latest | /usr/bin/awk '/zipball_url/ { print $2 }' | sed 's/[",]//g'` && unzip /tmp/munkitools.zip -d /tmp/munkitools && rm -rf /tmp/munkitools.zip | ||
RUN cp -r /tmp/munkitools/munki-munki*/code/client/* /munkitools && rm -rf /tmp/munkitools | ||
|
||
VOLUME [ "/munkirepo" ] | ||
|
||
# run entrypoint.sh | ||
ENTRYPOINT ["/usr/src/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
########### | ||
# BUILDER # | ||
########### | ||
|
||
# pull official base image | ||
FROM python:3.11-slim as builder | ||
|
||
# set work directory | ||
WORKDIR /usr/src/app | ||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y gcc default-libmysqlclient-dev python3-dev \ | ||
libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev \ | ||
build-essential libssl-dev libffi-dev libjpeg-dev \ | ||
libpq-dev liblcms2-dev libblas-dev libatlas-base-dev pkg-config curl unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# lint | ||
RUN pip install --upgrade pip | ||
COPY . /usr/src/app/ | ||
|
||
# install python dependencies | ||
COPY ./requirements.txt . | ||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt | ||
|
||
# download munkitools | ||
RUN curl -Lk -o /tmp/munkitools.zip `curl --silent https://api.github.com/repos/munki/munki/releases/latest | /usr/bin/awk '/zipball_url/ { print $2 }' | sed 's/[",]//g'` && unzip /tmp/munkitools.zip -d /tmp/munkitools && rm -rf /tmp/munkitools.zip | ||
|
||
|
||
######### | ||
# FINAL # | ||
######### | ||
|
||
# pull official base image | ||
FROM python:3.11-slim | ||
|
||
# create directory for the app user | ||
RUN mkdir -p /home/app | ||
RUN mkdir /munkirepo | ||
RUN mkdir /munkitools | ||
|
||
# create the appropriate directories | ||
ENV HOME=/home/app | ||
ENV APP_HOME=/home/app/web | ||
RUN mkdir $APP_HOME | ||
WORKDIR $APP_HOME | ||
|
||
# copy project | ||
COPY . $APP_HOME | ||
|
||
# install dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends nginx | ||
COPY --from=builder /usr/src/app/wheels /wheels | ||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache /wheels/* | ||
COPY --from=builder /tmp/munkitools /munkitools | ||
|
||
# nginx config | ||
COPY munkiwebadmin/munkiwebadmin.conf /etc/nginx/sites-available/default | ||
|
||
# static files | ||
RUN mkdir $APP_HOME/staticfiles | ||
RUN python manage.py collectstatic --noinput | ||
|
||
# volumes | ||
VOLUME [ "/munkirepo" ] | ||
|
||
# run entrypoint.prod.sh | ||
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"] | ||
EXPOSE 80 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
NAME="MunkiWebAdmin" # Name of the application | ||
DJANGODIR=/home/app/web # Django project directory | ||
SOCKFILE=/home/app/gunicorn.sock # we will communicte using this unix socket | ||
USER=root # the user to run as | ||
GROUP=root # the group to run as | ||
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | ||
DJANGO_SETTINGS_MODULE=munkiwebadmin.settings # which settings file should Django use | ||
|
||
|
||
if [ "$DATABASE" = "postgres" ] | ||
then | ||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z $SQL_HOST $SQL_PORT; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
fi | ||
|
||
# migrate database | ||
python manage.py migrate | ||
|
||
echo "Starting $NAME as `whoami`" | ||
|
||
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE | ||
|
||
# Start your Django Unicorn | ||
gunicorn munkiwebadmin.wsgi:application \ | ||
--name $NAME \ | ||
--workers $NUM_WORKERS \ | ||
--user=$USER --group=$GROUP \ | ||
--bind=0.0.0.0:8000 \ | ||
--log-level=debug \ | ||
--log-file=/home/app/gunicorn.log \ | ||
--daemon | ||
|
||
exec nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
if [ "$DATABASE" = "postgres" ] | ||
then | ||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z $SQL_HOST $SQL_PORT; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
fi | ||
|
||
# python manage.py flush --no-input | ||
python manage.py migrate | ||
|
||
exec "$@" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#upstream munkiwebadmin { | ||
# fail_timeout=0 means we always retry an upstream even if it failed | ||
# to return a good HTTP response (in case the Unicorn master nukes a | ||
# single worker for timing out). | ||
# server unix:/home/app/gunicorn.sock fail_timeout=0; | ||
#} | ||
|
||
upstream munkiwebadmin { | ||
server localhost:8000; | ||
} | ||
|
||
server { | ||
listen 80; | ||
client_max_body_size 12G; | ||
access_log /home/app/access.log; | ||
error_log /home/app/error.log; | ||
location /static/ { | ||
alias /home/app/web/staticfiles/; | ||
} | ||
location /media/ { | ||
alias /munkirepo; | ||
} | ||
location / { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
if (!-f $request_filename) { | ||
proxy_pass http://munkiwebadmin; | ||
break; | ||
} | ||
} | ||
# Error pages | ||
error_page 500 502 503 504 /500.html; | ||
location = /500.html { | ||
root /home/app/web/munkiwebadmin/templates/; | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.