-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
104 additions
and
17 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 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 |
---|---|---|
|
@@ -24,4 +24,5 @@ yarn-error.log* | |
|
||
**/venv | ||
**/__pycache__ | ||
**/*.sqlite3 | ||
**/*.sqlite3 | ||
**/static/* |
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,23 @@ | ||
FROM phusion/baseimage | ||
|
||
RUN mkdir -p /easytrack/react | ||
COPY ./django ./static ./requirements.*.txt /easytrack/ | ||
COPY ./react/build /easytrack/react | ||
|
||
RUN apt-get -y update | ||
RUN apt-get install -qy \ | ||
nginx \ | ||
postgresql-client \ | ||
python3 \ | ||
python3-pip | ||
RUN pip3 install --upgrade pip | ||
RUN pip3 install -r /easytrack/requirements.dev.txt | ||
COPY runit/uwsgi /etc/service/uwsgi | ||
COPY nginx/easytrack.conf /etc/nginx/sites-available/easytrack.conf | ||
RUN rm /etc/nginx/sites-enabled/* | ||
RUN ln -s /etc/nginx/sites-available/easytrack.conf /etc/nginx/sites-enabled/easytrack.conf | ||
COPY runit/nginx /etc/service/nginx | ||
|
||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
EXPOSE 80 |
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,4 @@ | ||
[uwsgi] | ||
module=config.wsgi:application | ||
#http=127.0.0.1:8000 | ||
socket=127.0.0.1:8000 |
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,29 @@ | ||
upstream django { | ||
#server unix:///home/evgene-petrenko/Projects/easy-track/django/easytrack.sock; | ||
server 127.0.0.1:8000; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
server_name _; | ||
|
||
charset utf-8; | ||
|
||
location /static { | ||
root /home/evgene-petrenko/Projects/easy-track/; | ||
} | ||
|
||
location /api/ { | ||
include uwsgi_params; | ||
uwsgi_pass django; | ||
} | ||
|
||
location /admin { | ||
include uwsgi_params; | ||
uwsgi_pass django; | ||
} | ||
|
||
location / { | ||
root /home/evgene-petrenko/Projects/easy-track/react/build; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
django==3.0.7 | ||
django-cors-headers==3.3.0 | ||
# django-cors-headers==3.3.0 | ||
djangorestframework==3.11.0 | ||
unidecode==1.1.1 | ||
djangorestframework-simplejwt==4.4.0 |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
source /mymdb/venv/bin/activate | ||
|
||
export PGPASSWORD="$DJANGO_DB_PASSWORD" | ||
psql \ | ||
-h "$DJANGO_DB_HOST" \ | ||
-p "$DJANGO_DB_PORT" \ | ||
-U "$DJANGO_DB_USER" \ | ||
-d "$DJANGO_DB_NAME" | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "no db server" | ||
exit 1 | ||
fi | ||
|
||
pushd /mymdb/django | ||
|
||
python manage.py migrate | ||
|
||
if [[ $? != 0 ]]; then | ||
"echo can't migrate" | ||
exit 2 | ||
fi | ||
|
||
popd | ||
|
||
exec /sbin/setuser www-data uwsgi --ini /etc/uwsgi/apps-enabled/mymdb.ini |
В данном случае, чистить уже поздно и даже вредно так как это приведет к дополнительному слою и не уменьшит размер изображения.
apt-get clean
нужно делать в том же слое что и остальные команды apt-get. Кстати,apt-get update -y
я бы тоже объединил сapt-get install
.Также команды COPY по возможности выполняют после установки пакетов и окружения -- в этом случае изображения собираются быстрее так как Docker может брать слои из кэша. Если же COPY выполняется до команд установки, то это может сбросить кэш и все будет устанавливаться заново каждый раз. (Но лучше это все проверить лично, на случае, если я ошибаюсь или в Docker-е что-нибудь поменяли.)