Merge branch 'develop'. Version 0.1.0
						commit
						9932abe9d1
					
				@ -1,21 +1,38 @@
 | 
			
		||||
#FROM python:3.7-alpine
 | 
			
		||||
FROM python:3.7
 | 
			
		||||
LABEL maintainer="drew@androiddrew.comw"
 | 
			
		||||
 | 
			
		||||
# Set environmental variables
 | 
			
		||||
ENV PYTHONUNBUFFERED 1
 | 
			
		||||
ENV DJANGO_ENV production
 | 
			
		||||
ENV PYTHONDONTWRITEBYTECODE 1
 | 
			
		||||
 | 
			
		||||
# Set Working Directory
 | 
			
		||||
WORKDIR /code
 | 
			
		||||
 | 
			
		||||
# install psycopg2
 | 
			
		||||
#RUN apk update \
 | 
			
		||||
#    && apk add --virtual build-deps gcc python3-dev musl-dev \
 | 
			
		||||
#    && apk add postgresql-dev \
 | 
			
		||||
#    && pip install psycopg2 \
 | 
			
		||||
#    && apk del build-deps
 | 
			
		||||
 | 
			
		||||
# Install dependencies
 | 
			
		||||
RUN pip install --upgrade pip
 | 
			
		||||
COPY ./requirements.txt /code/requirements.txt
 | 
			
		||||
RUN pip install -r /code/requirements.txt
 | 
			
		||||
RUN pip install gunicorn
 | 
			
		||||
 | 
			
		||||
# Copy entrypoint.sh
 | 
			
		||||
COPY ./entrypoint.sh /code/entrypoint.sh
 | 
			
		||||
 | 
			
		||||
# Copy code to image
 | 
			
		||||
COPY . /code/
 | 
			
		||||
WORKDIR /code/
 | 
			
		||||
 | 
			
		||||
RUN python manage.py collectstatic
 | 
			
		||||
RUN useradd wagtail && chown -R wagtail /code
 | 
			
		||||
 | 
			
		||||
RUN apt update && apt -y install netcat
 | 
			
		||||
 | 
			
		||||
RUN useradd wagtail
 | 
			
		||||
RUN chown -R wagtail /code
 | 
			
		||||
USER wagtail
 | 
			
		||||
 | 
			
		||||
EXPOSE 8000
 | 
			
		||||
CMD exec gunicorn cms.wsgi:application --bind 0.0.0.0:8000 --workers 3
 | 
			
		||||
# run entrypoint.sh
 | 
			
		||||
ENTRYPOINT ["/code/entrypoint.sh"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
echo "Waiting for PostgreSQL"
 | 
			
		||||
 | 
			
		||||
while ! nc -z $DB_HOST $DB_PORT; do
 | 
			
		||||
    sleep 0.1
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
echo "PostgreSQL started"
 | 
			
		||||
 | 
			
		||||
python manage.py flush --no-input
 | 
			
		||||
python manage.py migrate
 | 
			
		||||
python manage.py collectstatic --no-input
 | 
			
		||||
 | 
			
		||||
echo "Migratation and static file collection Successful"
 | 
			
		||||
 | 
			
		||||
exec "$@"
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
Django>=2.1,<2.2
 | 
			
		||||
wagtail>=2.3,<2.4
 | 
			
		||||
psycopg2>=2.7.5
 | 
			
		||||
whitenoise>=4.1
 | 
			
		||||
psycopg2==2.7.5
 | 
			
		||||
gunicorn==19.9.0
 | 
			
		||||
@ -0,0 +1,4 @@
 | 
			
		||||
FROM nginx:1.15.0-alpine
 | 
			
		||||
 | 
			
		||||
RUN rm /etc/nginx/conf.d/default.conf
 | 
			
		||||
COPY prod.conf /etc/nginx/conf.d
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
upstream wagtail_app {
 | 
			
		||||
    server cms:5000;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
 | 
			
		||||
  listen 80;
 | 
			
		||||
 | 
			
		||||
  location / {
 | 
			
		||||
    proxy_pass        http://wagtail_app;
 | 
			
		||||
    proxy_redirect    off;
 | 
			
		||||
    proxy_set_header  Host $host;
 | 
			
		||||
    proxy_set_header  X-Real-IP $remote_addr;
 | 
			
		||||
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
			
		||||
    proxy_set_header  X-Forwarded-Host $server_name;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location /media/ {
 | 
			
		||||
    alias /var/www/datasketch/media/;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location /static/ {
 | 
			
		||||
    alias /var/www/datasketch/static/;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue