Commit 3aa4a493 authored by Addshore's avatar Addshore 🏄
Browse files

Docs and scripts for toolforge deployment

parent 6a01a898
......@@ -7,10 +7,10 @@ organization:
app:
title: Wikimedia Backstage
# Should be the same as backend.baseUrl when using the `app-backend` plugin
baseUrl: http://localhost:8000
baseUrl: https://backstage.toolforge.org
backend:
baseUrl: http://localhost:8000
baseUrl: https://backstage.toolforge.org
listen:
port: 8000
csp:
......
# Wikimedia toolforge deployment
https://backstage.toolforge.org/
https://toolsadmin.wikimedia.org/tools/id/backstage
## Update Deployment
On the bastion:
```sh
~/src/deploy/pull
~/src/deploy/webservice-shell
```
In the container:
```sh
~/src/deploy/build
exit
```
And back on the bastion:
```sh
~/src/deploy/sync-www
~/src/deploy/webservice-restart
```
## Initial Install
**Clone the code into `src`:**
```sh
git clone https://github.com/addshore/wm-backstage.git src
```
**Start an interactive node session:**
```sh
webservice --backend=kubernetes --cpu 1 --mem 2Gi node12 shell
```
**Install yarn into `yarn`:**
```sh
mkdir yarn
cd ~/yarn
npm install yarn
```
A `yarn` binary is now accessible at `~/yarn/node_modules/.bin/yarn`
**Install and initially build backstage:**
Taking inspiration from https://backstage.io/docs/deployment/docker
```sh
cd ~/src
~/yarn/node_modules/.bin/yarn install --frozen-lockfile --ignore-engines
~/yarn/node_modules/.bin/yarn tsc
~/yarn/node_modules/.bin/yarn build
```
The `--ignore-engines` is currently needed, else we get a `error rollup-plugin-dts@3.0.2: The engine "node" is incompatible with this module. Expected version ">=v12.22.1". Got "12.21.0"`
**Build a deployment:**
```sh
mkdir -p ~/build
cd ~/build
cp ~/src/yarn.lock ~/src/package.json ~/src/packages/backend/dist/skeleton.tar.gz ~/build
tar xzf skeleton.tar.gz && rm skeleton.tar.gz
~/yarn/node_modules/.bin/yarn install --frozen-lockfile --production --network-timeout 300000 --ignore-engines
cp ~/src/packages/backend/dist/bundle.tar.gz ~/src/app-config.yaml ~/src/app-config.production.yaml ~/build
tar xzf bundle.tar.gz && rm bundle.tar.gz
```
Can we make this yarn install any faster by copying something from somewhere?
**Move it to deployment:**
Not in a node / webservice container!
```sh
mkdir -p ~/www/js
rsync -avu --delete /data/project/backstage/build/ /data/project/backstage/www/js/
```
**Run it:**
```sh
webservice --backend=kubernetes node12 start
```
#!/bin/bash
# Build a new copy of the app to deploy
cd ~/src
~/yarn/node_modules/.bin/yarn install --frozen-lockfile --ignore-engines
~/yarn/node_modules/.bin/yarn tsc
~/yarn/node_modules/.bin/yarn build
cd ~/build
cp ~/src/yarn.lock ~/src/package.json ~/src/packages/backend/dist/skeleton.tar.gz ~/build
tar xzf skeleton.tar.gz && rm skeleton.tar.gz
~/yarn/node_modules/.bin/yarn install --frozen-lockfile --production --network-timeout 300000 --ignore-engines
cp ~/src/packages/backend/dist/bundle.tar.gz ~/src/app-config.yaml ~/src/app-config.production.yaml ~/build
tar xzf bundle.tar.gz && rm bundle.tar.gz
\ No newline at end of file
#!/bin/bash
# Pull the latest code
cd ~/src
git pull
\ No newline at end of file
#!/bin/bash
# Sync the built app with the deployment directory
rsync -avu --delete /data/project/backstage/build/ /data/project/backstage/www/js/
#!/bin/bash
# Restart a started webservice
webservice --backend=kubernetes node12 restart
\ No newline at end of file
#!/bin/bash
# Start an interactive shell in a container
webservice --backend=kubernetes --cpu 1 --mem 2Gi node12 shell
\ No newline at end of file
......@@ -7,7 +7,7 @@
},
"scripts": {
"dev": "concurrently \"yarn start-frontend\" \"yarn start-backend\"",
"start": "node packages/backend --config app-config.yaml",
"start": "node packages/backend --config app-config.yaml --config app-config.production.yaml",
"start-frontend": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"build": "lerna run build",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment