Skip to content

Commit

Permalink
refactor(yukon)!: add builder script
Browse files Browse the repository at this point in the history
BREAKING CHANGE: renamed `yukon` folder to `client` and `yukon-server` folder to `server`.
  • Loading branch information
n0bodysec committed Sep 29, 2022
1 parent 3bafd1d commit c474158
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 22 deletions.
8 changes: 4 additions & 4 deletions yukon/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# private data
.data/
.env
yukon-server/ssl/*
!yukon-server/ssl/.gitkeep
server/ssl/*
!server/ssl/.gitkeep

# yukon sources
yukon/src/
yukon-server/src/
client/src/
server/src/

# nginx files
www/*
Expand Down
37 changes: 28 additions & 9 deletions yukon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,49 @@ Yukon CPPS Emulator Docker Image

## 🃏 Features

- Almost Plug N' Play!
- Almost Plug n' Play!
- Develop without installing node or dependencies.
- Run isolated instances (and multiple instances too!).
- Secured environment.

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

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

1. Copy `.env.example` to `.env` and edit it accordingly.
2. Run the included `builder` compose service.
3. Copy the contents of the `assets` **repository** into `www` folder.
4. Run `docker compose up -d`.

```sh
cp .env.example .env
docker compose up builder
git clone <assets-repo-url> www/assets
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 `yukon/src` and `yukon-server/src`, respectively.
4. Build `yukon` and copy the contents of the `yukon/src/dist` folder into `www` folder.
5. Copy the contents of the `yukon/src/assets` folder into `www` folder.
3. Clone `yukon` and `yukon-server` to `client/src` and `server/src`, respectively.
4. Build `yukon` and copy the contents of the `client/src/dist` folder into `www` folder.
5. Copy the contents of the `client/src/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. Run `docker compose up -d`.

```sh
git clone https://github.com/wizguin/yukon.git yukon/src
git clone https://github.com/wizguin/yukon-server.git yukon-server/src
cp .env.example .env
git clone https://github.com/wizguin/yukon.git client/src
git clone https://github.com/wizguin/yukon-server.git server/src
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 yukon/src/assets/ www
cp -r yukon/src/dist/* www
cp -r client/src/assets/ www
cp -r client/src/dist/* www
mkdir -p www/assets/scripts/lib/ruffle
wget -qO- https://github.com/ruffle-rs/ruffle/releases/download/nightly-2022-09-14/ruffle-nightly-2022_09_14-web-selfhosted.zip | busybox unzip -d www/assets/scripts/lib/ruffle -
docker compose up -d
Expand Down
File renamed without changes.
45 changes: 37 additions & 8 deletions yukon/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.9'
services:
client:
image: yukon/client
build: ./yukon
build: ./client
restart: unless-stopped
ports: [ '${WEB_PORT}:80' ]
networks: [ 'default' ]
Expand All @@ -22,7 +22,7 @@ services:
server:
image: yukon/server
build:
context: ./yukon-server
context: ./server
args:
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
Expand All @@ -32,12 +32,12 @@ services:
depends_on: [ 'mariadb' ]
env_file: [ '.env' ]
volumes:
- ./yukon-server/ssl:/etc/ssl/yukon:ro
- ./yukon-server/src:/srv/yukon-server/
- ./server/ssl:/etc/ssl/yukon:ro
- ./server/src:/srv/server/
- ./templates/config.json.template:/srv/templates/config.json.template
command: [
'dockerize',
'-template', '/srv/templates/config.json.template:/srv/yukon-server/config/config.json',
'-template', '/srv/templates/config.json.template:/srv/server/config/config.json',
'-wait', 'tcp://${MARIADB_HOST}:${MARIADB_PORT}', '-timeout', '20s',
'npx', 'pm2-runtime', 'start', 'ecosystem.config.js'
]
Expand All @@ -50,16 +50,45 @@ services:
env_file: [ '.env' ]
volumes:
- ./.data:/var/lib/mysql
- ./yukon-server/src/yukon.sql:/docker-entrypoint-initdb.d/yukon.sql:ro
- ./server/src/yukon.sql:/docker-entrypoint-initdb.d/yukon.sql:ro

node:
image: node:alpine
profiles: [ 'dev' ]
working_dir: /srv/yukon
command: [ 'sh' ]
volumes:
- ./yukon/src:/srv/yukon/client
- ./yukon-server/src:/srv/yukon/server
- ./client/src:/srv/yukon/client
- ./server/src:/srv/yukon/server

builder:
image: node:alpine
profiles: [ 'dev' ]
working_dir: /srv/yukon
env_file: [ '.env' ]
volumes:
- ./client/src:/srv/yukon/client
- ./server/src:/srv/yukon/server
- ./www:/srv/yukon/www
environment:
CLIENT_BRANCH: main
SERVER_BRANCH: master
command:
- /bin/sh
- -c
- |
apk add --no-cache git
git clone https://github.com/wizguin/yukon.git client
git clone https://github.com/wizguin/yukon-server.git server
cd client && npm ci && npm run build
cd ../server && npm ci && npm run build
cd .. && cp -r client/assets www && cp -r client/dist/* www
mkdir -p www/assets/scripts/lib/ruffle
wget -qO res.json https://api.github.com/repos/ruffle-rs/ruffle/releases
node -p "require('./res.json').flatMap(x => x.assets).find(y => y.browser_download_url.includes('selfhosted')).browser_download_url;" | xargs -n1 wget -qO ruffle.zip
unzip -d www/assets/scripts/lib/ruffle ruffle.zip
echo "Chowning all files..."
chown -R $$PUID:$$PGID *
networks:
db:
Expand Down
2 changes: 1 addition & 1 deletion yukon/yukon-server/Dockerfile → yukon/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
# run as non-root user
USER node

WORKDIR /srv/yukon-server
WORKDIR /srv/server
CMD ["npm", "run", "start"]
File renamed without changes.

0 comments on commit c474158

Please sign in to comment.