diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000000..47cd67e8ef --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,38 @@ +# Deploying Backstage + +## Heroku + +Deploying to heroku is relatively easy following these steps. + +First, make sure you have the [heroku CLI installed](https://devcenter.heroku.com/articles/heroku-cli) and log into it as well as loging into Heroku's [container registry](https://devcenter.heroku.com/articles/container-registry-and-runtime). + +```bash +$ heroku login +$ heroku container:login +``` + +You _might_ also need to set your Heroku app's stack to `container` + +```bash +$ heroku stack:set container -a +``` + +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. + +```bash +$ heroku container:push web -a +$ heroku container:release web -a +``` + +With that, you should have Backstage up and running! diff --git a/Dockerfile b/Dockerfile index 3220e46f5f..39d51a35f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,3 @@ 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 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;' diff --git a/deployment/Dockerfile.heroku b/deployment/Dockerfile.heroku new file mode 100644 index 0000000000..15878c67da --- /dev/null +++ b/deployment/Dockerfile.heroku @@ -0,0 +1,24 @@ +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;' diff --git a/default.conf.template b/deployment/default.conf.template similarity index 98% rename from default.conf.template rename to deployment/default.conf.template index 9d9ff7f3e2..61c32aa95e 100644 --- a/default.conf.template +++ b/deployment/default.conf.template @@ -5,4 +5,4 @@ server { root /usr/share/nginx/html; index index.html; } -} \ No newline at end of file +}