Skip to content

Commit 6be8d41

Browse files
authored
Merge pull request #11 from La-404-Devinci/dev
Add databases and docker CD
2 parents 1a74cbb + 0c18eb7 commit 6be8d41

File tree

10 files changed

+263
-8
lines changed

10 files changed

+263
-8
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
branches:
44
- master
55
- main
6+
- dev
67
- features/*
78
- feature/*
89
- fix/*

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
npm install
2424
npm run build
2525
cd ../backend
26+
docker compose up -d
2627
npm install
2728
npm run build
2829
screen -S 404 -X quit

backend/.env.example

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
PORT=3000
1+
PORT=3000
2+
3+
JWT_SECRET="s3cr3t"
4+
5+
MYSQL_USER="pixelwar"
6+
MYSQL_PASSWORD="pixelwar"
7+
MYSQL_HOST="localhost"
8+
MYSQL_PORT="3336"
9+
MYSQL_DATABASE="pixelwar"
10+
11+
REDIS_USER=""
12+
REDIS_PASSWORD=""
13+
REDIS_HOST="localhost"
14+
REDIS_PORT="3337"
15+
REDIS_DATABASE="0"

backend/.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"es2021": true,
44
"node": true
55
},
6+
"ignorePatterns": ["node_modules", "dist", "data"],
67
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
78
"parser": "@typescript-eslint/parser",
89
"parserOptions": {

backend/.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
node_modules
2-
dist
3-
out
4-
build
2+
dist/
3+
out/
4+
build/
55
.env
66
.*.local.env
7-
index.js
7+
index.js
8+
data/

backend/database/mysql.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as mysql from "mysql2/promise";
2+
3+
const access: mysql.PoolOptions = {
4+
user: process.env.MYSQL_USER,
5+
password: process.env.MYSQL_PASSWORD,
6+
host: process.env.MYSQL_HOST,
7+
port: parseInt(process.env.MYSQL_PORT ?? "3306"),
8+
database: process.env.MYSQL_DATABASE,
9+
connectionLimit: 15,
10+
};
11+
12+
export default mysql.createPool(access);

backend/database/redis.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createClient } from "redis";
2+
3+
const user = process.env.REDIS_USER;
4+
const password = process.env.REDIS_PASSWORD;
5+
const credentials = user && password ? `${user}:${password}@` : "";
6+
7+
const databaseNumber = process.env.REDIS_DATABASE;
8+
const database = databaseNumber ? `/${databaseNumber}` : "";
9+
10+
const redisUrl = `redis://${credentials}${process.env.REDIS_HOST}:${process.env.REDIS_PORT}${database}`;
11+
12+
const getRedisClient = createClient({
13+
url: redisUrl,
14+
})
15+
.on("error", (err) => console.log("Redis Client Error", err))
16+
.connect();
17+
18+
export default getRedisClient;

backend/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "3"
2+
3+
services:
4+
mysql:
5+
image: mysql:8.3.0
6+
container_name: mysql-pixelwar
7+
restart: always
8+
environment:
9+
MYSQL_ROOT_PASSWORD: root
10+
MYSQL_DATABASE: pixelwar
11+
MYSQL_USER: pixelwar
12+
MYSQL_PASSWORD: pixelwar
13+
ports:
14+
- "0.0.0.0:3336:3306"
15+
volumes:
16+
- ./data/mysql:/var/lib/mysql
17+
redis:
18+
image: redis:7.2.4
19+
container_name: redis-pixelwar
20+
restart: always
21+
ports:
22+
- "0.0.0.0:3337:6379"
23+
volumes:
24+
- ./data/redis:/data

backend/package-lock.json

Lines changed: 183 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)