Skip to content

Commit

Permalink
Merge pull request #4 from vatger/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
ngoerlitz committed Jun 15, 2023
2 parents 18746f6 + d34d313 commit 1fba96c
Show file tree
Hide file tree
Showing 52 changed files with 1,114 additions and 252 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
dist
dist

README.md
CONTRIBUTING.md
32 changes: 32 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker CI/CD

on:
push:
branches: [ "dev" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
run: |
docker build --pull -t ${{ env.REGISTRY }}/${{ github.repository }}:latest .
docker push ${{ env.REGISTRY }}/${{ github.repository }}:latest
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
dist
.github

package.json
package-lock.json
Expand All @@ -14,6 +15,7 @@ docker-compose.yml
.prettierignore
.gitlab-ci.yml

CONTRIBUTING.md
README.md
.env
.env.example
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ RUN npm install --quiet --unsafe-perm --no-progress --no-audit --include=dev

COPY . .

CMD npm run dev
RUN npm run build

CMD npm run run
12 changes: 6 additions & 6 deletions db/config/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const dotenv = require('dotenv');
const dotenv = require("dotenv");

dotenv.config();

Expand All @@ -15,16 +15,16 @@ module.exports = {
username: process.env.CI_DB_USERNAME,
password: process.env.CI_DB_PASSWORD,
database: process.env.CI_DB_NAME,
host: '127.0.0.1',
host: "127.0.0.1",
port: 3306,
dialect: 'mysql',
dialect: "mysql",
},
production: {
username: process.env.PROD_DB_USERNAME,
password: process.env.PROD_DB_PASSWORD,
database: process.env.PROD_DB_NAME,
host: process.env.PROD_DB_HOSTNAME,
port: process.env.PROD_DB_PORT,
dialect: 'mysql',
}
};
dialect: "mysql",
},
};
2 changes: 2 additions & 0 deletions db/migrations/20221115171242-create-user-table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { DataType } = require("sequelize-typescript");

//TODO: Check relationships (explicitly on delete and on update). These should not all be cascade!

const DataModelAttributes = {
id: {
type: DataType.INTEGER,
Expand Down
8 changes: 8 additions & 0 deletions db/migrations/20221115171243-create-user-session-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const DataModelAttributes = {
type: DataType.UUID,
allowNull: false,
},
browser_uuid: {
type: DataType.UUID,
allowNull: false,
},
client: {
type: DataType.STRING(100),
allowNull: true,
},
user_id: {
type: DataType.INTEGER,
allowNull: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const DataModelAttributes = {
key: "id",
},
onUpdate: "cascade",
onDelete: "cascade",
onDelete: "set null",
},
comment: {
type: DataType.TEXT,
Expand All @@ -73,7 +73,7 @@ const DataModelAttributes = {
key: "id",
},
onUpdate: "cascade",
onDelete: "cascade",
onDelete: "set null",
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
Expand Down
70 changes: 70 additions & 0 deletions db/migrations/20221115171265-create-notification-tables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const { DataType } = require("sequelize-typescript");

const CourseInformationModelAttributes = {
id: {
type: DataType.INTEGER,
primaryKey: true,
autoIncrement: true,
},
uuid: {
type: DataType.UUID,
allowNull: false,
},
user_id: {
type: DataType.INTEGER,
allowNull: false,
references: {
model: "users",
key: "id",
},
onUpdate: "cascade",
onDelete: "cascade",
},
author_id: {
type: DataType.INTEGER,
allowNull: true,
references: {
model: "users",
key: "id",
},
onUpdate: "cascade",
onDelete: "set null",
},
content_de: {
type: DataType.TEXT("medium"),
allowNull: false,
},
content_en: {
type: DataType.TEXT("medium"),
allowNull: false,
},
link: {
type: DataType.STRING(255),
allowNull: true,
},
icon: {
type: DataType.STRING(50),
allowNull: true,
},
severity: {
type: DataType.ENUM("default", "info", "success", "danger"),
allowNull: true,
},
read: {
type: DataType.BOOLEAN,
allowNull: false,
default: true,
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
};

module.exports = {
async up(queryInterface) {
await queryInterface.createTable("notifications", CourseInformationModelAttributes);
},

async down(queryInterface) {
await queryInterface.dropTable("notifications");
},
};
14 changes: 8 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
version: "3.9"
services:
backend:
build: .
image: ghcr.io/vatger/trainingcenter-backend:latest
depends_on:
mysql:
condition: service_started
env_file:
- .env
environment:
- APP_DEBUG
- APP_LOG_SQL
- APP_PORT=8001
- APP_PORT=80
- APP_HOST
- APP_KEY
- APP_VERSION
Expand All @@ -32,13 +30,17 @@ services:
- DB_USERNAME
- DB_PASSWORD
ports:
- "8001:8001"
- "5001:80"

frontend:
image: ghcr.io/vatger/trainingcenter-frontend:latest
ports:
- "5002:80"
mysql:
image: mysql
restart: always
ports:
- "3306:3306"
- "5000:3306"
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_USER: trainingcenter
Expand Down
Loading

0 comments on commit 1fba96c

Please sign in to comment.