Skip to content

Commit

Permalink
refactor(yukon)!: remove custom images
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Dockerize is not bundled anymore, you must download and place it under .data/dockerize.tar.gz
  • Loading branch information
n0bodysec committed Sep 30, 2022
1 parent bb49733 commit b346881
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 66 deletions.
6 changes: 6 additions & 0 deletions yukon/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ GAME_BLIZZARD_PORT=6112
# It is fine to leave this so long as you
# do not use the builder service.
#
# DOCKERIZE_VERSION
# -----------------
# The dockerize version to download.
# It is only used by the builder service.
#
##############################################

ASSETS_TAR_URL=https://gitea.com/USERNAME/REPOSITORY/archive/master.tar.gz
DOCKERIZE_VERSION=v0.6.1
14 changes: 6 additions & 8 deletions yukon/.gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# private data
# Private Data
.data/
.env
server/ssl/*
!server/ssl/.gitkeep

# yukon sources
client/src/
server/src/
# Yukon Sources
client/
server/

# nginx files
# Nginx root files (client container)
www/*
!www/.gitkeep
!www/.gitkeep
27 changes: 15 additions & 12 deletions yukon/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Yukon

Yukon CPPS Emulator Docker Image
Yukon is an HTML5 CPPS written in JavaScript. This repository contains a series of Docker compose services to help you develop and deploy Yukon faster and more securely.

## 🃏 Features

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

## 🚀 Deploy (automatic setup)
Expand All @@ -29,24 +30,26 @@ If you prefer to clone the sources and build it manually, you can follow the nex

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/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.
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. Run `docker compose up -d`.
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/src
git clone https://github.com/wizguin/yukon-server.git server/src
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/src/assets/ www
cp -r client/src/dist/* www
cp -r client/assets/ www
cp -r client/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 -
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 -d
```

Expand Down
6 changes: 0 additions & 6 deletions yukon/client/Dockerfile

This file was deleted.

65 changes: 38 additions & 27 deletions yukon/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,47 @@ version: '3.9'

services:
client:
image: yukon/client
build: ./client
image: nginx:alpine
restart: unless-stopped
ports: [ '${WEB_PORT}:80' ]
networks: [ 'default' ]
depends_on: [ 'server' ]
command: ['dockerize', '-template', '/etc/nginx/conf.d/yukon.conf.template:/etc/nginx/conf.d/yukon.conf', 'nginx', '-g', 'daemon off;']
command:
- /bin/sh
- -c
- |
tar -C /usr/local/bin -xzvf /root/dockerize.tar.gz
dockerize -template /etc/nginx/conf.d/yukon.conf.template:/etc/nginx/conf.d/yukon.conf nginx "-g daemon off;"
environment:
WEB_HOSTNAME: ${WEB_HOSTNAME}
GAME_ADDRESS: ${GAME_ADDRESS}
GAME_LOGIN_PORT: ${GAME_LOGIN_PORT}
GAME_BLIZZARD_PORT: ${GAME_BLIZZARD_PORT}
volumes:
- ./.data/dockerize.tar.gz:/root/dockerize.tar.gz:ro
- /dev/null:/etc/nginx/conf.d/default.conf:ro
- ./www:/usr/share/nginx/html:ro
- ./templates/yukon.conf.template:/etc/nginx/conf.d/yukon.conf.template:ro

server:
image: yukon/server
build: ./server
image: node:alpine
restart: unless-stopped
# ports: [ '${GAME_LOGIN_PORT}:${GAME_LOGIN_PORT}', '${GAME_BLIZZARD_PORT}:${GAME_BLIZZARD_PORT}' ]
networks: [ 'default', 'db' ]
depends_on: [ 'mariadb' ]
env_file: [ '.env' ]
command: dockerize -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
working_dir: /srv/server
command:
- /bin/sh
- -c
- |
tar -C /usr/local/bin -xzvf /root/dockerize.tar.gz
dockerize -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
volumes:
- ./server/ssl:/etc/ssl/yukon:ro
- ./server/src:/srv/server/
- ./.data/dockerize.tar.gz:/root/dockerize.tar.gz:ro
- ./.data/ssl:/etc/ssl/yukon:ro
- ./server:/srv/server/
- ./templates/config.json.template:/srv/templates/config.json.template:ro

mariadb:
Expand All @@ -40,42 +52,41 @@ services:
networks: [ 'db' ]
env_file: [ '.env' ]
volumes:
- ./.data:/var/lib/mysql
- ./server/src/yukon.sql:/docker-entrypoint-initdb.d/yukon.sql:ro

node:
image: node:alpine
profiles: [ 'dev' ]
working_dir: /srv/yukon
command: [ 'sh' ]
volumes:
- ./client/src:/srv/yukon/client
- ./server/src:/srv/yukon/server
- ./.data/mariadb:/var/lib/mysql
- ./server/yukon.sql:/docker-entrypoint-initdb.d/yukon.sql:ro

builder:
image: node:alpine
profiles: [ 'dev' ]
working_dir: /srv/yukon
environment: ['ASSETS_TAR_URL=${ASSETS_TAR_URL}']
env_file: [ '.env' ]
volumes:
- ./client/src:/srv/yukon/client
- ./server/src:/srv/yukon/server
- ./www:/srv/yukon/www
- ./:/srv/yukon
command:
- /bin/sh
- -c
- |
apk add --no-cache git
mkdir -p www/assets/scripts/lib/ruffle .data/ssl
wget -qO .data/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$$DOCKERIZE_VERSION.tar.gz
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
wget -qO /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 -qO /tmp/ruffle.zip
unzip -d www/assets/scripts/lib/ruffle /tmp/ruffle.zip
wget -qO- $$ASSETS_TAR_URL | tar --strip-components=1 -C www/assets -xzvf-
node:
image: node:alpine
profiles: [ 'dev' ]
working_dir: /srv/yukon
command: [ 'sh' ]
volumes:
- ./client:/srv/yukon/client
- ./server:/srv/yukon/server

networks:
db:
13 changes: 0 additions & 13 deletions yukon/server/Dockerfile

This file was deleted.

Empty file removed yukon/server/ssl/.gitkeep
Empty file.

0 comments on commit b346881

Please sign in to comment.