Ripped out unneeded stuff
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
name: Publish Docker image
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [ published ]
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v1.*
|
|
||||||
jobs:
|
|
||||||
push_to_registry:
|
|
||||||
name: Push Docker Image to Docker Hub
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check Out The Repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Get Smart Tag
|
|
||||||
id: prepare
|
|
||||||
uses: Surgo/docker-smart-tag-action@v1
|
|
||||||
with:
|
|
||||||
docker_image: krgamestudios/chat-server
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Push to Docker Hub
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.prepare.outputs.tag }}
|
|
||||||
platforms: amd64,arm
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
Copyright (c) 2021 Kayne Ruse, KR Game Studios
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
//setup
|
|
||||||
const readline = require('readline');
|
|
||||||
const fs = require('fs');
|
|
||||||
const crypto = require("crypto");
|
|
||||||
|
|
||||||
const uuid = (bytes = 16) => crypto.randomBytes(bytes).toString("hex");
|
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
|
||||||
input: process.stdin,
|
|
||||||
output: process.stdout,
|
|
||||||
terminal: false
|
|
||||||
});
|
|
||||||
|
|
||||||
//manually promisify this (util didn't work)
|
|
||||||
const question = (prompt, def = null) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
rl.question(`${prompt}${def ? ` (${def})` : ''}: `, answer => {
|
|
||||||
//loop on required
|
|
||||||
if (def === null && !answer) {
|
|
||||||
return resolve(question(prompt, def));
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolve(answer || def);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//questions
|
|
||||||
(async () => {
|
|
||||||
//project configuration
|
|
||||||
const appName = await question('App Name', 'chat');
|
|
||||||
const appWebAddress = await question('Web Addr', `${appName}.example.com`);
|
|
||||||
const appPort = await question('App Port', '3300');
|
|
||||||
|
|
||||||
const appDBUser = await question('DB User', appName);
|
|
||||||
const appDBPass = await question('DB Pass', uuid());
|
|
||||||
const dbRootPass = await question('DB Root Pass');
|
|
||||||
|
|
||||||
const appSecretAccess = await question('Access Token Secret', uuid(32));
|
|
||||||
|
|
||||||
const supportEmail = await question('Support Email', 'example@example.com');
|
|
||||||
|
|
||||||
//generate the files
|
|
||||||
const ymlfile = `
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
|
||||||
${appName}:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
ports:
|
|
||||||
- "${appPort}"
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.${appName}router.rule=Host(\`${appWebAddress}\`)"
|
|
||||||
- "traefik.http.routers.${appName}router.entrypoints=websecure"
|
|
||||||
- "traefik.http.routers.${appName}router.tls.certresolver=myresolver"
|
|
||||||
- "traefik.http.routers.${appName}router.service=${appName}service@docker"
|
|
||||||
- "traefik.http.services.${appName}service.loadbalancer.server.port=${appPort}"
|
|
||||||
environment:
|
|
||||||
- WEB_PORT=${appPort}
|
|
||||||
- DB_HOSTNAME=database
|
|
||||||
- DB_DATABASE=${appName}
|
|
||||||
- DB_USERNAME=${appDBUser}
|
|
||||||
- DB_PASSWORD=${appDBPass}
|
|
||||||
- DB_TIMEZONE=Australia/Sydney
|
|
||||||
- SECRET_ACCESS=${appSecretAccess}
|
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
depends_on:
|
|
||||||
- database
|
|
||||||
database:
|
|
||||||
image: mariadb:latest
|
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: ${appName}
|
|
||||||
MYSQL_USER: ${appDBUser}
|
|
||||||
MYSQL_PASSWORD: ${appDBPass}
|
|
||||||
MYSQL_ROOT_PASSWORD: ${dbRootPass}
|
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
volumes:
|
|
||||||
- ./mysql:/var/lib/mysql
|
|
||||||
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro
|
|
||||||
traefik_${appName}:
|
|
||||||
container_name: ${appName}_traefik
|
|
||||||
image: "traefik:v2.4"
|
|
||||||
container_name: "traefik"
|
|
||||||
command:
|
|
||||||
- "--log.level=ERROR"
|
|
||||||
- "--api.insecure=false"
|
|
||||||
- "--providers.docker=true"
|
|
||||||
- "--providers.docker.exposedbydefault=false"
|
|
||||||
- "--entrypoints.websecure.address=:443"
|
|
||||||
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
|
|
||||||
- "--certificatesresolvers.myresolver.acme.email=${supportEmail}"
|
|
||||||
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
volumes:
|
|
||||||
- "./letsencrypt:/letsencrypt"
|
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
networks:
|
|
||||||
app-network:
|
|
||||||
driver: bridge
|
|
||||||
`;
|
|
||||||
|
|
||||||
const dockerfile = `
|
|
||||||
FROM node:15
|
|
||||||
WORKDIR "/app"
|
|
||||||
COPY package*.json ./
|
|
||||||
COPY . /app
|
|
||||||
RUN npm install --production
|
|
||||||
EXPOSE ${appPort}
|
|
||||||
USER node
|
|
||||||
ENTRYPOINT ["bash", "-c"]
|
|
||||||
CMD ["sleep 10 && npm start"]
|
|
||||||
`;
|
|
||||||
|
|
||||||
const sqlfile = `
|
|
||||||
CREATE DATABASE IF NOT EXISTS ${appName};
|
|
||||||
CREATE USER IF NOT EXISTS '${appDBUser}'@'%' IDENTIFIED BY '${appDBPass}';
|
|
||||||
GRANT ALL PRIVILEGES ON ${appName}.* TO '${appDBUser}'@'%';
|
|
||||||
`;
|
|
||||||
|
|
||||||
fs.writeFileSync('docker-compose.yml', ymlfile);
|
|
||||||
fs.writeFileSync('Dockerfile', dockerfile);
|
|
||||||
fs.writeFileSync('startup.sql', sqlfile);
|
|
||||||
})()
|
|
||||||
.then(() => rl.close())
|
|
||||||
.catch(e => console.error(e))
|
|
||||||
;
|
|
||||||
Generated
+1
-1
@@ -5,10 +5,10 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "chat-server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/krgamestudios/chat-server#readme",
|
"homepage": "https://github.com/krgamestudios/chat-server#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
|||||||
+1
-2
@@ -10,11 +10,10 @@ const io = require('socket.io')(server, {
|
|||||||
origin: '*'
|
origin: '*'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
|
|
||||||
//config
|
//config
|
||||||
app.use(bodyParser.json());
|
app.use(express.json());
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
//database connection
|
//database connection
|
||||||
|
|||||||
Reference in New Issue
Block a user