diff --git a/Dockerfile b/Dockerfile index 6a2ba5d..ca12eca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,13 @@ RUN \ yarn build FROM nginx:alpine -RUN apk add --no-cache bash COPY --from=build-env /opt/app/build /var/www -COPY --from=build-env /opt/app/default.conf /etc/nginx/conf.d/default.conf +COPY --from=build-env /opt/app/envsubt.sh /etc/nginx/templates/envsubt.sh +COPY --from=build-env /opt/app/default.conf /etc/nginx/templates/default.conf.template WORKDIR /var/www -EXPOSE 80 5000 -CMD ["/bin/bash", "-c", "nginx -g \"daemon off;\""] + +RUN apk add --no-cache bash + +ENV PORT=80 + +CMD ["/bin/sh", "-c", "/etc/nginx/templates/envsubt.sh && nginx -g \"daemon off;\""] diff --git a/default.conf b/default.conf index 874edf4..973b036 100644 --- a/default.conf +++ b/default.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen ${PORT}; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; diff --git a/envsubt.sh b/envsubt.sh new file mode 100755 index 0000000..a21eebb --- /dev/null +++ b/envsubt.sh @@ -0,0 +1 @@ +envsubst '\${PORT}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf \ No newline at end of file