|
1 | 1 | # Pull a pre-built alpine docker image with nginx and python3 installed
|
2 | 2 | FROM tiangolo/uwsgi-nginx:python3.6-alpine3.7
|
3 | 3 |
|
| 4 | +# Set the port on which the app runs; make both values the same. |
| 5 | +# |
| 6 | +# IMPORTANT: When deploying to Azure App Service, go to the App Service on the Azure |
| 7 | +# portal, navigate to the Applications Settings blade, and create a setting named |
| 8 | +# WEBSITES_PORT with a value that matches the port here (the Azure default is 80). |
| 9 | +# You can also create a setting through the App Service Extension in VS Code. |
4 | 10 | ENV LISTEN_PORT=8000
|
5 | 11 | EXPOSE 8000
|
6 | 12 |
|
| 13 | +# Indicate where uwsgi.ini lives |
| 14 | +ENV UWSGI_INI uwsgi.ini |
| 15 | + |
| 16 | +# Tell nginx where static files live. Typically, developers place static files for |
| 17 | +# multiple apps in a shared folder, but for the purposes here we can use the one |
| 18 | +# app's folder. Note that when multiple apps share a folder, you should create subfolders |
| 19 | +# with the same name as the app underneath "static" so there aren't any collisions |
| 20 | +# when all those static files are collected together, as when using Django's |
| 21 | +# collectstatic command. |
| 22 | +ENV STATIC_URL /app/static_collected |
| 23 | + |
7 | 24 | # Copy the app files to a folder and run it from there
|
8 | 25 | WORKDIR /app
|
9 | 26 | ADD . /app
|
10 | 27 |
|
| 28 | +# Make app folder writeable for the sake of db.sqlite3, and make that file also writeable. |
| 29 | +# Ideally you host the database somewhere else so that the app folders can remain read only. |
| 30 | +# Without these permissions you see the errors "unable to open database file" and |
| 31 | +# "attempt to write to a readonly database", respectively, whenever the app attempts to |
| 32 | +# write to the database. |
| 33 | +RUN chmod g+w /app |
| 34 | +RUN chmod g+w /app/db.sqlite3 |
| 35 | + |
| 36 | +# Make sure dependencies are installed |
11 | 37 | RUN python3 -m pip install -r requirements.txt
|
12 |
| -CMD ["uwsgi", "uwsgi.ini"] |
|
0 commit comments