Skip to content

Commit

Permalink
Readded support for a single-container docker deployment as this is n…
Browse files Browse the repository at this point in the history
…eeded for the heroku example app
  • Loading branch information
ChristophNiehoff committed May 10, 2021
1 parent c19a54e commit ca59bed
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ deploy/
build/
db/
**/*.test.js
.heroku/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ matrix:
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
- echo "$HEROKU_API_KEY" | docker login -u "$HEROKU_USER" --password-stdin registry.heroku.com
script:
- docker build -t $REPO:$COMMIT .
- docker build -f heroku/Dockerfile -t $REPO:$COMMIT .
- docker tag $REPO:$COMMIT $REPO:latest
- docker tag $REPO:$COMMIT $REPO:$TRAVIS_TAG
- docker tag $REPO:$COMMIT $REPO:$TRAVIS_TAG
Expand Down
21 changes: 21 additions & 0 deletions heroku/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:latest
WORKDIR /usr/src/app
ENV PORT 80

RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash
RUN apt-get update && apt-get install -y nginx supervisor nodejs
RUN rm -rf /var/lib/apt/lists/*

COPY package*.json ./
RUN npm install
COPY . .
COPY heroku/conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY heroku/conf/nginx.conf /etc/nginx/sites-available/default

RUN npm run build
RUN cp -a build/. /var/www/html/

# add support for $PORT env variable
CMD sed -i -e 's/$PORT/'"$PORT"'/g' /etc/nginx/sites-available/default && /usr/bin/supervisord

20 changes: 20 additions & 0 deletions heroku/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen $PORT;
root /var/www/html;
index index.html;
server_name _;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://localhost:8001/;
}
location /socket.io/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:8000/socket.io/;
}
}
20 changes: 20 additions & 0 deletions heroku/conf/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[supervisord]
nodaemon=true

[program:app]
directory=/usr/src/app
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=npm run server

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
priority=900
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
username=www-data
autorestart=true

0 comments on commit ca59bed

Please sign in to comment.