Skip to content

Commit 3a44650

Browse files
authored
Merge pull request #16 from tmshn/port-configurable
Make listen port configurable with `LISTEN_PORT`.
2 parents 2f27729 + 51ab43c commit 3a44650

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,26 @@ ENV NGINX_MAX_UPLOAD 1m
101101
COPY ./app /app
102102
```
103103

104+
### Custom listen port
105+
106+
By default, the container made from this image will listen on port 80.
107+
108+
To change this behavior, set the `LISTEN_PORT` environment variable.
109+
110+
You can do that in your `Dockerfile`, it would look something like:
111+
112+
```Dockerfile
113+
FROM tiangolo/uwsgi-nginx:python3.6
114+
115+
ENV LISTEN_PORT 8080
116+
117+
COPY ./app /app
118+
```
119+
104120
## What's new
105121

122+
* 2017-12-08: Now you can configure which port the container should listen on, using the environment variable `LISTEN_PORT`.
123+
106124
* 2017-08-09: You can set a custom maximum upload file size using an environment variable `NGINX_MAX_UPLOAD`, by default it has a value of `0`, that allows unlimited upload file sizes. This differs from Nginx's default value of 1 MB. It's configured this way because that's the simplest experience a developer that is not expert in Nginx would expect.
107125

108126
* 2017-08-09: Now you can override where to look for the `uwsgi.ini` file, and with that, change the default directory from `/app` to something else, using the envirnoment variable `UWSGI_INI`.

latest/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0}
66
# Generate Nginx config for maximum upload file size
77
echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf
88

9+
# Get the listen port for Nginx, default to 80
10+
USE_LISTEN_PORT=${LISTEN_PORT:-80}
11+
# Modify Nignx config for listen port
12+
sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf
13+
914
echo -e "WARNING: YOU SHOULDN'T BE USING THE 'latest' DOCKER TAG.
1015
1116
The Docker tag 'latest' will be for Python 3.6 soon.

python2.7/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ ENV UWSGI_INI /app/uwsgi.ini
4141
# ENV NGINX_MAX_UPLOAD 1m
4242
ENV NGINX_MAX_UPLOAD 0
4343

44+
# By default, Nginx listens on port 80.
45+
# To modify this, change LISTEN_PORT environment variable.
46+
# (in a Dockerfile or with an option for `docker run`)
47+
ENV LISTEN_PORT 80
48+
4449
# Copy the entrypoint that will generate Nginx additional configs
4550
COPY entrypoint.sh /entrypoint.sh
4651
RUN chmod +x /entrypoint.sh

python2.7/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0}
55
# Generate Nginx config for maximum upload file size
66
echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf
77

8+
# Get the listen port for Nginx, default to 80
9+
USE_LISTEN_PORT=${LISTEN_PORT:-80}
10+
# Modify Nignx config for listen port
11+
sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf
12+
813
exec "$@"

python3.5/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ ENV UWSGI_INI /app/uwsgi.ini
4141
# ENV NGINX_MAX_UPLOAD 1m
4242
ENV NGINX_MAX_UPLOAD 0
4343

44+
# By default, Nginx listens on port 80.
45+
# To modify this, change LISTEN_PORT environment variable.
46+
# (in a Dockerfile or with an option for `docker run`)
47+
ENV LISTEN_PORT 80
48+
4449
# Copy the entrypoint that will generate Nginx additional configs
4550
COPY entrypoint.sh /entrypoint.sh
4651
RUN chmod +x /entrypoint.sh

python3.5/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0}
66
# Generate Nginx config for maximum upload file size
77
echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf
88

9+
# Get the listen port for Nginx, default to 80
10+
USE_LISTEN_PORT=${LISTEN_PORT:-80}
11+
# Modify Nignx config for listen port
12+
sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf
13+
914
exec "$@"

python3.6/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ ENV UWSGI_INI /app/uwsgi.ini
4141
# ENV NGINX_MAX_UPLOAD 1m
4242
ENV NGINX_MAX_UPLOAD 0
4343

44+
# By default, Nginx listens on port 80.
45+
# To modify this, change LISTEN_PORT environment variable.
46+
# (in a Dockerfile or with an option for `docker run`)
47+
ENV LISTEN_PORT 80
48+
4449
# Copy the entrypoint that will generate Nginx additional configs
4550
COPY entrypoint.sh /entrypoint.sh
4651
RUN chmod +x /entrypoint.sh

python3.6/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0}
66
# Generate Nginx config for maximum upload file size
77
echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf
88

9+
# Get the listen port for Nginx, default to 80
10+
USE_LISTEN_PORT=${LISTEN_PORT:-80}
11+
# Modify Nignx config for listen port
12+
sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf
13+
914
exec "$@"

0 commit comments

Comments
 (0)