Modify copying files in Dockerfile to rely more on volume

Move entrypoint
This commit is contained in:
Dustin Pianalto 2019-12-25 18:19:05 -09:00
parent eb01d32071
commit 5c46df0b2a
3 changed files with 22 additions and 11 deletions

View File

@ -30,13 +30,14 @@ WORKDIR /code
RUN apk update && apk add nginx && apk add supervisor RUN apk update && apk add nginx && apk add supervisor
COPY requirements/base.txt . RUN mkdir requirements
COPY requirements/production.txt .
RUN pip install -r production.txt COPY requirements/base.txt requirements/base.txt
COPY requirements/production.txt requirements/production.txt
RUN pip install -r requirements/production.txt
COPY requirements/web.txt . COPY requirements/web.txt requirements/web.txt
RUN pip install -r web.txt RUN pip install -r requirements/web.txt
RUN rm -f /etc/nginx/sites-enabled/default RUN rm -f /etc/nginx/sites-enabled/default
RUN rm -f /etc/nginx/conf.d/default.conf RUN rm -f /etc/nginx/conf.d/default.conf
@ -53,12 +54,6 @@ RUN rm -rf /tmp/*
RUN mkdir -p /tmp/logs/nginx RUN mkdir -p /tmp/logs/nginx
RUN mkdir -p /tmp/logs/geeksbot RUN mkdir -p /tmp/logs/geeksbot
RUN mkdir -p /code/geeksbot_web RUN mkdir -p /code/geeksbot_web
COPY ./* /code/
WORKDIR /code/geeksbot_web
# RUN sed -i 's/\r$//g' ./entrypoint
# RUN chmod +x ./entrypoint
# PostgreSQL DB Connection Info # PostgreSQL DB Connection Info
ENV POSTGRES_HOST geeksbot-db.c3omjx35ryzn.us-east-1.rds.amazonaws.com ENV POSTGRES_HOST geeksbot-db.c3omjx35ryzn.us-east-1.rds.amazonaws.com
@ -87,4 +82,6 @@ ENV WEB_CONCURRENCY 4
EXPOSE 80 8000 443 EXPOSE 80 8000 443
COPY entrypoint .
ENTRYPOINT [ "./entrypoint" ] ENTRYPOINT [ "./entrypoint" ]

View File

@ -4,6 +4,8 @@ set -o errexit
set -o pipefail set -o pipefail
set -o nounset set -o nounset
cd geeksbot_web
python manage.py collectstatic --noinput python manage.py collectstatic --noinput
python manage.py makemigrations --noinput python manage.py makemigrations --noinput
python manage.py migrate python manage.py migrate

12
user_data.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
yum update -y
export AWS_DEFAULT_REGION='us-east-1'
instance_id=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 associate-address --instance-id $instance_id --public-ip "34.238.62.161"
mkdir /code || exit
cd /code || exit
git clone git@github.com:dustinpianalto/geeksbot_web.git
cd geeksbot_web || exit
docker build . -t geeksbot_web || exit
docker run -d -v /code/geeksbot_web:/code -v /root/.ssh:/root/.ssh:ro --name geeksbot_web --restart always geeksbot_web:latest || exit