Skip to content

Commit

Permalink
refactor(yukon): setup script & deploy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
n0bodysec authored Apr 15, 2024
1 parent 8634102 commit 081760e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
35 changes: 3 additions & 32 deletions yukon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,18 @@ Yukon is an HTML5 CPPS written in JavaScript. This repository contains a series
- Multiple instances support.
- Secured environment.

## 🚀 Deploy (automatic setup)
## 🚀 Deploy

If you want to deploy Yukon with almost no effort, follow the next steps:

1. Copy `.env.example` to `.env` and edit it accordingly.
> Please make sure to set **ASSETS_REPOSITORY** correctly.
2. Run the `builder` compose service.
2. Run the `setup` compose service.
3. Run `docker compose up -d`.

```sh
cp .env.example .env
docker compose up builder
docker compose up -d
```

## 🚀 Deploy (manual setup)

If you prefer to clone the sources and build it manually, you can follow the next steps:

1. Create a `docker-compose.override.yml` file and edit it to suit your needs (***optional***).
2. Copy `.env.example` to `.env` and edit it accordingly.
3. Clone `yukon` and `yukon-server` to `client` and `server`, respectively.
4. Build `yukon` and copy the contents of the `client/dist` folder into `www` folder.
5. Copy the contents of the `client/assets` folder into `www` folder.
6. Copy the contents of the `assets` **repository** into `www` folder.
7. Download a copy of [ruffle self-hosted](https://ruffle.rs/#downloads) and put it into `www/assets/scripts/lib/ruffle` folder.
8. Build `yukon-server`.
9. Download a copy of [dockerize](https://github.com/jwilder/dockerize/releases) for `Alpine Linux` and place it under `.data/dockerize.tar.gz`.
10. Run `docker compose up -d`.

```sh
cp .env.example .env
git clone https://github.com/wizguin/yukon.git client
git clone https://github.com/wizguin/yukon-server.git server
docker compose run node sh -c "cd client && npm i && npm run build && cd ../server && npm i && npm run build"
git clone <assets-repo-url> www/assets
cp -r client/assets/ www
cp -r client/dist/* www
mkdir -p www/assets/scripts/lib/ruffle
wget -qO- <ruffle-selfhosted-zip-url> | busybox unzip -d www/assets/scripts/lib/ruffle -
wget -qO .data/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz
docker compose up setup
docker compose up -d
```

Expand Down
10 changes: 5 additions & 5 deletions yukon/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ check_command "unzip"
########################################################################################################################################

# Setup
BASE_DIR=$(pwd)
CURRENT_ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/;s/i686/386/;s/armv[0-9]l/armel/;s/armv[0-9]hf/armhf/;s/ppc64le/ppc64le/')

# Clone required repositories
Expand All @@ -30,24 +31,23 @@ git clone -b $ASSETS_BRANCH --depth 1 $ASSETS_REPOSITORY www/assets
# Download required files
echo "TASK: Downloading required files..."
wget -O /tmp/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-$CURRENT_ARCH-$DOCKERIZE_VERSION.tar.gz
wget -O /tmp/res.json https://api.github.com/repos/ruffle-rs/ruffle/releases
node -p "require('/tmp/res.json').flatMap(x => x.assets).find(y => y.browser_download_url.includes('selfhosted')).browser_download_url;" | xargs -n1 wget -O /tmp/ruffle.zip
wget -O- https://api.github.com/repos/ruffle-rs/ruffle/releases | grep -m1 -oE "https://.*selfhosted.*\.zip" | xargs wget -O /tmp/ruffle.zip

# Build client
echo "TASK: Building client..."
cd client
cd $BASE_DIR/client
npm ci
npm run build

# Build server
echo "TASK: Building server..."
cd ../server
cd $BASE_DIR/server
npm ci
npm run build

# Move files
echo "TASK: Moving required files..."
cd .. && cp -r client/assets www && cp -r client/dist/* www
cd $BASE_DIR && cp -r client/assets www && cp -r client/dist/* www
unzip -d www/assets/scripts/lib/ruffle /tmp/ruffle.zip
mkdir -p .data/ssl && tar -xzvf /tmp/dockerize.tar.gz -C .data/

Expand Down

0 comments on commit 081760e

Please sign in to comment.