Commit 997a433 1 parent ce82600 commit 997a433 Copy full SHA for 997a433
File tree 3 files changed +21
-8
lines changed
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,9 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
142
142
# nginx stage to serve static assets and proxy requests to api container
143
143
FROM nginx:$NGINX_VERSION AS web
144
144
145
- ENV INSTALL_PATH=/usr/src/app
145
+ ENV INSTALL_PATH=/usr/src/app \
146
+ API_SERVICE_HOST=api \
147
+ API_SERVICE_PORT=3000
146
148
147
149
# Create non-root user
148
150
RUN addgroup -g 3000 -S dmpgroup && \
@@ -163,13 +165,14 @@ COPY nginx.conf /etc/nginx/nginx.conf
163
165
RUN chown dmpuser:dmpgroup /etc/nginx/nginx.conf && \
164
166
chmod 664 /etc/nginx/nginx.conf
165
167
168
+ # Set up an entrypoint script to replace variables dynamically
169
+ COPY nginx-entrypoint.sh /usr/local/bin/entrypoint.sh
170
+ RUN chmod +x /usr/local/bin/entrypoint.sh
171
+
166
172
USER dmpuser
167
173
168
174
EXPOSE 80
169
175
170
- # Replace environment variables in nginx.conf and overwrite the file
171
- CMD envsubst '${API_URL}' < /etc/nginx/nginx.conf | tee /etc/nginx/nginx.conf > /dev/null \
172
- # Set to read-only after substitution
173
- && chmod 644 /etc/nginx/nginx.conf \
174
- # Start Nginx in the foreground to keep the container running
175
- && exec nginx -g 'daemon off;'
176
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
177
+
178
+ CMD ["nginx", "-g", "daemon off;"]
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Replace environment variables in nginx.conf and overwrite the file
4
+ envsubst ' ${API_SERVICE_HOST} ${API_SERVICE_PORT}' < /etc/nginx/nginx.conf | tee /etc/nginx/nginx.conf > /dev/null
5
+
6
+ # Set to read-only after substitution
7
+ chmod 644 /etc/nginx/nginx.conf
8
+
9
+ # Execute the main process
10
+ exec " $@ "
Original file line number Diff line number Diff line change 67
67
}
68
68
# Proxy configuration for API
69
69
location / {
70
- proxy_pass ${API_URL };
70
+ proxy_pass http://${API_SERVICE_HOST}:${API_SERVICE_PORT };
71
71
72
72
# Standard proxy headers
73
73
proxy_set_header Host $host ;
You can’t perform that action at this time.
0 commit comments