Skip to content

Commit

Permalink
Prepare initial version of configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Dove6 committed Nov 14, 2021
0 parents commit 5c237ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nppBackup
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM nginx

ENV REST_API_READ_HOSTNAME=localhost
ENV REST_API_READ_PORT=8081
ENV REST_API_WRITE_HOSTNAME=localhost
ENV REST_API_WRITE_PORT=8082

COPY upstream.location.template /etc/nginx/

RUN perl -0pe 's/root\s+\/usr\/share\/nginx\/html;\s+index\s+index\.html\s+index\.htm;/proxy_pass http:\/\/\$rest_api_host;/igs' /etc/nginx/conf.d/default.conf > /etc/nginx/conf.d/default.conf.part && \
echo "include /etc/nginx/upstream.location;" | cat - /etc/nginx/conf.d/default.conf.part > /etc/nginx/conf.d/default.conf

RUN echo "envsubst '\$REST_API_READ_HOSTNAME,\$REST_API_READ_PORT,\$REST_API_WRITE_HOSTNAME,\$REST_API_WRITE_PORT' < /etc/nginx/upstream.location.template > /etc/nginx/upstream.location && cat /etc/nginx/upstream.location" > /docker-entrypoint.d/40-envsubst-upstream-location.sh && \
chmod a+x /docker-entrypoint.d/40-envsubst-upstream-location.sh

CMD ["nginx", "-g", "daemon off;"]
4 changes: 4 additions & 0 deletions upstream.location.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
map $request_method $rest_api_host {
GET $REST_API_READ_HOSTNAME:$REST_API_READ_PORT;
default $REST_API_WRITE_HOSTNAME:$REST_API_WRITE_PORT;
}

0 comments on commit 5c237ef

Please sign in to comment.