Skip to content

Commit b8c388a

Browse files
author
Manuel Rauber
committed
chore: use dynamic port for heroku
1 parent c14fbeb commit b8c388a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

backend/src/servers/http-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class HttpServer {
3030
}
3131

3232
listen(): void {
33-
// TODO: dynamic port
34-
this.server.listen(8080, () => debug('Server is up and running on port %s', 8080));
33+
const port = process.env.PORT || 8080;
34+
this.server.listen(port, () => debug('Server is up and running on port %s', port));
3535
}
3636
}

frontend/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ FROM nginx:alpine
2020
WORKDIR /app
2121

2222
COPY --from=build-env /app/dist/smudgy /usr/share/nginx/html
23-
COPY --from=build-env /app/config/nginx.conf /etc/nginx/conf.d/default.conf
23+
COPY --from=build-env /app/config/nginx.conf /etc/nginx/conf.d/default.template
24+
25+
CMD sh -c "envsubst \"`env | awk -F = '{printf \" \\\\$%s\", $1}'`\" < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

frontend/config/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
2-
listen 80;
2+
listen ${NGINX_PORT};
33

44
# add mime types if needed:
55
include mime.types;

0 commit comments

Comments
 (0)