Merge pull request #422 from spotify/rugvip/merge

merge Dockerfile and nginx config with heroku deployment
This commit is contained in:
Patrik Oldsberg
2020-03-31 09:04:53 +02:00
committed by GitHub
6 changed files with 19 additions and 48 deletions
+1 -12
View File
@@ -17,18 +17,7 @@ You _might_ also need to set your Heroku app's stack to `container`
$ heroku stack:set container -a <your-app>
```
There are two small tweaks made to Backstage's default Dockerfile to run on Heroku:
1. Do not run nginx as the `nginx` user.
2. Replace the standard port (80) in `/etc/nginx/conf.d/default.conf` with the wildcard `$PORT`, which Heroku will set for us.
These changes are in the `deployment/Dockerfile.heroku` file, which you will need to copy into your root directory before deploying:
```bash
$ cp deployment/Dockerfile.heroku Dockerfile
```
With these changes, we can build/push the Docker image to Heroku's container registry and release it to the `web` worker.
We can now build/push the Docker image to Heroku's container registry and release it to the `web` worker.
```bash
$ heroku container:push web -a <your-app>
+8 -2
View File
@@ -8,11 +8,17 @@ COPY plugins /app/plugins
RUN yarn
COPY . .
COPY lerna.json tsconfig.json .eslintignore .eslintrc.js /app/
COPY scripts/ /app/scripts
RUN yarn build
FROM nginx:mainline
COPY --from=builder /app/packages/app/build /usr/share/nginx/html
COPY ./docker/default.conf /etc/nginx/conf.d/default.conf
COPY docker/default.conf.template /etc/nginx/conf.d/default.conf.template
COPY docker/run.sh /usr/local/bin/run.sh
CMD run.sh
ENV PORT 80
-24
View File
@@ -1,24 +0,0 @@
FROM node:12 as builder
WORKDIR /app
COPY package.json yarn.lock .yarnrc .npmrc /app/
COPY .yarn /app/.yarn
COPY packages /app/packages
COPY plugins /app/plugins
RUN yarn
COPY . .
RUN yarn build
FROM nginx:mainline
COPY --from=builder /app/packages/app/build /usr/share/nginx/html
# Run nginx as root
RUN sed -i 's/user nginx.*$//' /etc/nginx/nginx.conf
# Copy in the nginx conf template and replace "$PORT" with the environment variable set by heroku
COPY deployment/default.conf.template /etc/nginx/conf.d/default.conf.template
CMD /bin/bash -c "envsubst '\$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf" && nginx -g 'daemon off;'
-8
View File
@@ -1,8 +0,0 @@
server {
listen $PORT default_server;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
@@ -1,5 +1,5 @@
server {
listen 80;
listen $PORT;
server_name localhost;
#charset koi8-r;
@@ -20,4 +20,3 @@ server {
root /usr/share/nginx/html;
}
}
Executable
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Run nginx as root
sed -i 's/user nginx.*$//' /etc/nginx/nginx.conf
# Write selected env vars to nginx config
envsubst '$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
exec nginx -g 'daemon off;'