From b346881a72a1b197e9fcd3eb6669c643593acf1f Mon Sep 17 00:00:00 2001 From: Nobody Date: Fri, 30 Sep 2022 06:47:27 -0300 Subject: [PATCH] refactor(yukon)!: remove custom images BREAKING CHANGE: Dockerize is not bundled anymore, you must download and place it under .data/dockerize.tar.gz --- yukon/.env.example | 6 ++++ yukon/.gitignore | 14 ++++----- yukon/README.md | 27 ++++++++-------- yukon/client/Dockerfile | 6 ---- yukon/docker-compose.yml | 65 +++++++++++++++++++++++---------------- yukon/server/Dockerfile | 13 -------- yukon/server/ssl/.gitkeep | 0 7 files changed, 65 insertions(+), 66 deletions(-) delete mode 100644 yukon/client/Dockerfile delete mode 100644 yukon/server/Dockerfile delete mode 100644 yukon/server/ssl/.gitkeep diff --git a/yukon/.env.example b/yukon/.env.example index a80134e..de4c8e0 100644 --- a/yukon/.env.example +++ b/yukon/.env.example @@ -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 diff --git a/yukon/.gitignore b/yukon/.gitignore index 586cd5f..3cbf795 100644 --- a/yukon/.gitignore +++ b/yukon/.gitignore @@ -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 \ No newline at end of file diff --git a/yukon/README.md b/yukon/README.md index 3936c05..667acc9 100644 --- a/yukon/README.md +++ b/yukon/README.md @@ -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) @@ -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 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- | 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 ``` diff --git a/yukon/client/Dockerfile b/yukon/client/Dockerfile deleted file mode 100644 index 898e4be..0000000 --- a/yukon/client/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM nginx:alpine - -ENV DOCKERIZE_VERSION=v0.6.1 -RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz diff --git a/yukon/docker-compose.yml b/yukon/docker-compose.yml index 781554c..7102492 100644 --- a/yukon/docker-compose.yml +++ b/yukon/docker-compose.yml @@ -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: @@ -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: diff --git a/yukon/server/Dockerfile b/yukon/server/Dockerfile deleted file mode 100644 index e5d0a9c..0000000 --- a/yukon/server/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM node:alpine - -# args & env -ARG WAIT_FOR_VERSION=4df3f9262d84cab0039c07bf861045fbb3c20ab7 -ENV DOCKERIZE_VERSION=v0.6.1 - -# install dockerize -RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz - -WORKDIR /srv/server -CMD ["npm", "run", "start"] diff --git a/yukon/server/ssl/.gitkeep b/yukon/server/ssl/.gitkeep deleted file mode 100644 index e69de29..0000000