Skip to content

Commit 0753b52

Browse files
authored
Merge pull request #50 from alfg/feature/envsubst
Add support for envsubst.
2 parents 04ae94f + a4d4a96 commit 0753b52

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ RUN apk add --update \
8282
x265-dev \
8383
yasm
8484

85-
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
85+
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
8686
RUN apk add --update fdk-aac-dev
8787

8888
# Get FFmpeg source.
@@ -126,8 +126,14 @@ RUN rm -rf /var/cache/* /tmp/*
126126
FROM alpine:3.11
127127
LABEL MAINTAINER Alfred Gutierrez <alf.g.jr@gmail.com>
128128

129+
# Set default ports.
130+
ENV HTTP_PORT 80
131+
ENV HTTPS_PORT 443
132+
ENV RTMP_PORT 1935
133+
129134
RUN apk add --update \
130135
ca-certificates \
136+
gettext \
131137
openssl \
132138
pcre \
133139
lame \
@@ -148,11 +154,13 @@ COPY --from=build-ffmpeg /usr/lib/libfdk-aac.so.2 /usr/lib/libfdk-aac.so.2
148154

149155
# Add NGINX path, config and static files.
150156
ENV PATH "${PATH}:/usr/local/nginx/sbin"
151-
ADD nginx.conf /etc/nginx/nginx.conf
157+
ADD nginx.conf /etc/nginx/nginx.conf.template
152158
RUN mkdir -p /opt/data && mkdir /www
153159
ADD static /www/static
154160

155161
EXPOSE 1935
156162
EXPOSE 80
157163

158-
CMD ["nginx"]
164+
CMD /bin/sh -c "envsubst" < /etc/nginx/nginx.conf.template > \
165+
/etc/nginx/nginx.conf && \
166+
nginx

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ This will enable HTTPS using a self-signed certificate supplied in [/certs](/cer
4545

4646
I recommend using [Certbot](https://certbot.eff.org/docs/install.html) from [Let's Encrypt](https://letsencrypt.org).
4747

48+
### Environment Variables
49+
This Docker image uses `envsubst` for environment variable substitution. You can define additional environment variables in `nginx.conf` as `${var}` and pass them in your `docker-compose` file or `docker` command.
50+
4851
### OBS Configuration
4952
* Stream Type: `Custom Streaming Server`
5053
* URL: `rtmp://localhost:1935/stream`

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ services:
77
- 1935:1935
88
- 8080:80
99
- 8443:443
10+
environment:
11+
- HTTP_PORT=80
12+
- RTMP_PORT=1935
1013
volumes:
1114
- ./certs:/opt/certs

nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ events {
88

99
rtmp {
1010
server {
11-
listen 1935;
11+
listen ${RTMP_PORT};
1212
chunk_size 4000;
1313

1414
application stream {
@@ -49,7 +49,7 @@ http {
4949
ssl_session_timeout 10m;
5050

5151
server {
52-
listen 80;
52+
listen ${HTTP_PORT};
5353

5454
# Uncomment these lines to enable SSL.
5555
# Update the ssl paths with your own certificate and private key.

0 commit comments

Comments
 (0)