Ripped out unneeded stuff

This commit is contained in:
2021-04-07 02:00:05 +10:00
parent 4ff507b0fa
commit 70712b9a87
8 changed files with 1 additions and 276 deletions
-39
View File
@@ -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/news-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
-11
View File
@@ -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.
-135
View File
@@ -1,135 +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', 'news');
const appWebAddress = await question('Web Addr', `${appName}.example.com`);
const appPort = await question('App Port', '3100');
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
- QUERY_LIMIT=10
- 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))
;
-1
View File
@@ -9,7 +9,6 @@
"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",
-1
View File
@@ -22,7 +22,6 @@
}, },
"homepage": "https://github.com/krgamestudios/news-server#readme", "homepage": "https://github.com/krgamestudios/news-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
View File
@@ -5,11 +5,10 @@ require('dotenv').config();
const express = require('express'); const express = require('express');
const app = express(); const app = express();
const server = require('http').Server(app); const server = require('http').Server(app);
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
-33
View File
@@ -1,33 +0,0 @@
#Query
GET https://dev-news.eggtrainer.com/news HTTP/1.1
###
#Publish
POST https://dev-news.eggtrainer.com/news HTTP/1.1
Content-Type: application/json
Authorization: Bearer
{
"title": "Hello World",
"author": "Kayne Ruse",
"body": "Lorem ipsum."
}
###
#Edit
PATCH https://dev-news.eggtrainer.com/news/1 HTTP/1.1
Content-Type: application/json
Authorization: Bearer
{
"title": "Goodnight World"
}
###
#Delete
DELETE https://dev-news.eggtrainer.com/news/1 HTTP/1.1
Content-Type: application/json
Authorization: Bearer
-54
View File
@@ -1,54 +0,0 @@
#Login to the auth-server
POST http://127.0.0.1:3200/auth/login HTTP/1.1
Content-Type: application/json
{
"email": "kayneruse@gmail.com",
"password": "helloworld"
}
###
#Refresh from the auth-server
POST http://127.0.0.1:3200/auth/token HTTP/1.1
Content-Type: application/json
{
"token": ""
}
###
#Query
GET http://127.0.0.1:3100/news HTTP/1.1
###
#Publish
POST http://127.0.0.1:3100/news HTTP/1.1
Content-Type: application/json
Authorization: Bearer
{
"title": "Hello World",
"author": "Kayne Ruse",
"body": "Lorem ipsum dolor sit amet..."
}
###
#Edit
PATCH http://127.0.0.1:3100/news/5 HTTP/1.1
Content-Type: application/json
Authorization: Bearer
{
"title": "Goodnight World"
}
###
#Delete
DELETE http://127.0.0.1:3100/news/4 HTTP/1.1
Content-Type: application/json
Authorization: Bearer