connection to db work but dist folder (compiled ts (js)) copied manually, not generated 😐

This commit is contained in:
kinou-p 2023-04-09 02:21:51 +02:00
parent d96861cddf
commit d241a0be0d
31 changed files with 8948 additions and 383 deletions

View File

@ -6,13 +6,13 @@
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/19 09:29:27 by apommier #+# #+# #
# Updated: 2023/03/22 17:51:22 by apommier ### ########.fr #
# Updated: 2023/04/04 18:14:43 by apommier ### ########.fr #
# #
# **************************************************************************** #
all:
# -mkdir -p /home/apommier/data/wordpress
-mkdir -p /home/apommier/data/postgresql
-mkdir -p /home/apommier/data/pgsql
docker-compose -f docker-compose.yml up --build
fclean: down
@ -22,6 +22,9 @@ fclean: down
-docker rmi -f $$(docker images -qa)
-docker volume rm $$(docker volume ls -q)
-docker network rm $$(docker network ls -q)
volume:
-docker volume rm $$(docker volume ls -q)
up:
docker-compose -f ./docker-compose.yml up

25
backend/.eslintrc.js Normal file
View File

@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};

35
backend/.gitignore vendored Normal file
View File

@ -0,0 +1,35 @@
# compiled output
/dist
/node_modules
# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# OS
.DS_Store
# Tests
/coverage
/.nyc_output
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

4
backend/.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

73
backend/README.md Normal file
View File

@ -0,0 +1,73 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Installation
```bash
$ npm install
```
## Running the app
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```
## Test
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
```
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

8
backend/nest-cli.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}

8371
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,78 @@
{
"name": "dockernodejspong",
"version": "1.0.0",
"description": "Web server to run an online pong",
"author": "apommier",
"main": "server.js",
"name": "test_nest",
"version": "0.0.1",
"description": "",
"type": "module",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"start": "node server.js"
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:build": "npm run build && npm run start:nodemon && rm -rf *.ts",
"start:nodemon": "nodemon --config nodemon.json",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"body-parser": "^1.20.2",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/typeorm": "^9.0.1",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"pg": "^8.10.0"
"pg": "^8.10.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"typeorm": "^0.3.13"
},
"devDependencies": {},
"license": "ISC"
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/express": "^4.17.13",
"@types/jest": "29.5.0",
"@types/node": "18.15.11",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.5.0",
"nodemon": "^2.0.22",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "29.0.5",
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "4.2.0",
"typescript": "^4.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

View File

@ -1,63 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/22 18:05:15 by apommier #+# #+# */
/* Updated: 2023/03/22 19:20:40 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
const express = require('express');
const bodyParser = require('body-parser');
// const { Client } = require('pg');
const { Pool } = require('pg');
const pool = new Pool({
host: '127.0.0.1',
port: 5432,
user: 'kinou',
password: 'pass',
database: 'postgreDB'
})
module.exports = pool;
pool.query('SELECT * FROM users', (err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.rows);
}
});
const app = express();
// const client = new Client({
// host: process.env.POSTGRES_HOST,
// port: process.env.POSTGRES_PORT,
// user: process.env.POSTGRES_USER,
// password: process.env.POSTGRES_PASSWORD,
// database: process.env.POSTGRES_DB
// });
// client.connect();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/api/test', (req, res) => {
res.send('Hello World!')
})
app.post('/api/login', (req, res) => {
// const formData = req.body;
// console.log(formData);
console.log('get request');
console.log(req.body);
res.status(201).json(req.body);
});
app.listen(5000, () => console.log('Server is up and running'));

View File

@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller.js';
import { AppService } from './app.service.js';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});

View File

@ -0,0 +1,28 @@
import { Controller, Get, Post } from '@nestjs/common';
import { AppService } from './app.service.js';
@Controller()
export class AppController2 {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
@Controller('api')
export class AppController {
constructor(private readonly appService: AppService) {}
@Get('login')
getHello(): string {
return this.appService.getHello();
}
@Post('login')
getHello2(): string {
return "post";
}
}
// "clean": "rm -rf /usr/src/app/src && rm -rf /usr/src/app/model && rm -rf /usr/src/app/config && rm -rf *.ts",

27
backend/src/app.module.ts Normal file
View File

@ -0,0 +1,27 @@
// import { Module } from '@nestjs/common';
// import { AppController } from './app.controller';
// import { AppService } from './app.service';
// @Module({
// imports: [],
// controllers: [AppController],
// providers: [AppService],
// })
// export class AppModule {}
import { Module } from '@nestjs/common';
import { AppController } from './app.controller.js';
import { AppService } from './app.service.js';
import { TypeOrmModule } from '@nestjs/typeorm';
import { getTypeOrmConfig } from './config/config.service.js';
@Module({
imports: [
TypeOrmModule.forRoot(getTypeOrmConfig())
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule { }

View File

@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@ -0,0 +1,96 @@
// // src/config/config.service.ts
// import { TypeOrmModuleOptions } from '@nestjs/typeorm';
// require('dotenv').config();
// class ConfigService {
// constructor(private env: { [k: string]: string | undefined }) { }
// private getValue(key: string, throwOnMissing = true): string {
// const value = this.env[key];
// if (!value && throwOnMissing) {
// throw new Error(`config error - missing env.${key}`);
// }
// return value;
// }
// public ensureValues(keys: string[]) {
// keys.forEach(k => this.getValue(k, true));
// return this;
// }
// public getPort() {
// return this.getValue('PORT', true);
// }
// public isProduction() {
// const mode = this.getValue('MODE', false);
// return mode != 'DEV';
// }
// public getTypeOrmConfig(): TypeOrmModuleOptions {
// return {
// type: 'postgres',
// host: this.getValue('POSTGRES_HOST'),
// port: parseInt(this.getValue('POSTGRES_PORT')),
// username: this.getValue('POSTGRES_USER'),
// password: this.getValue('POSTGRES_PASSWORD'),
// database: this.getValue('POSTGRES_DATABASE'),
// entities: ['**/*.entity{.ts,.js}'],
// migrationsTableName: 'migration',
// migrations: ['src/migration/*.ts'],
// // cli: {
// // migrationsDir: 'src/migration',
// // },
// ssl: this.isProduction(),
// };
// }
// }
// const configService = new ConfigService(process.env)
// .ensureValues([
// 'POSTGRES_HOST',
// 'POSTGRES_PORT',
// 'POSTGRES_USER',
// 'POSTGRES_PASSWORD',
// 'POSTGRES_DATABASE'
// ]);
// export { configService };
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
// require('dotenv').config();
// class ConfigService {
export const getTypeOrmConfig = (): TypeOrmModuleOptions => ({
// type: 'postgres',
// host: process.env.POSTGRES_HOST,
// port: parseInt(process.env.POSTGRES_PORT, 10),
// username: process.env.POSTGRES_USER,
// password: process.env.POSTGRES_PASSWORD,
// database: process.env.POSTGRES_DATABASE,
// entities: ['**/*.entity{.ts,.js}'],
// migrationsTableName: 'migration',
// migrations: ['src/migration/*.ts'],
// ssl: process.env.MODE !== 'DEV',
type: 'postgres',
host: 'postgresql',
port: 5432,
username: 'postgres',
password: 'pass',
database: 'postgres',
entities: ['**/*.entity{.ts,.js}'],
migrationsTableName: 'migration',
migrations: ['src/migration/*.ts'],
ssl: process.env.MODE !== 'DEV',
});
// }
// export { ConfigService };

8
backend/src/main.ts Normal file
View File

@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module.js';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();

View File

@ -0,0 +1,60 @@
// // import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
// import {Entity, PrimaryGeneratedColumn, Column} from 'typeorm';
// @Entity()
// export class User {
// @PrimaryGeneratedColumn()
// id: number;
// @Column()
// nickName: string;
// @Column()
// Password: string;
// @Column()
// email: string;
// @Column()
// password: string;
// @Column()
// win: number;
// @Column()
// loose: number;
// // friend
// // joined chat
// // jsp
// // prout
// }
// base.entity.ts
import { PrimaryGeneratedColumn, Column, UpdateDateColumn, CreateDateColumn } from 'typeorm';
export abstract class BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'boolean', default: true })
isActive: boolean;
@Column({ type: 'boolean', default: false })
isArchived: boolean;
@CreateDateColumn({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
createDateTime: Date;
@Column({ type: 'varchar', length: 300 })
createdBy: string;
@UpdateDateColumn({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
lastChangedDateTime: Date;
@Column({ type: 'varchar', length: 300 })
lastChangedBy: string;
@Column({ type: 'varchar', length: 300, nullable: true })
internalComment: string | null;
}

View File

@ -0,0 +1,13 @@
// item.entity.ts
import { Entity, Column } from 'typeorm';
import { BaseEntity } from './base.entity.js';
@Entity({ name: 'item' })
export class Item extends BaseEntity {
@Column({ type: 'varchar', length: 300 })
name: string;
@Column({ type: 'varchar', length: 300 })
description: string;
}

View File

@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

27
backend/tsconfig.json Normal file
View File

@ -0,0 +1,27 @@
{
"compilerOptions": {
// "module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
},
"exclude": [
"**/*",
"!/usr/src/app/dist/**/*"
]
}

View File

@ -37,7 +37,7 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend:5000;
proxy_pass http://backend:3000;
}

9
database/init.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# ALTER USER kinou WITH PASSWORD 'pass';
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --password ""$POSTGRES_PASSWORD"" <<-EOSQL
CREATE USER kinou WITH PASSWORD 'pass';
CREATE DATABASE postgreDB;
GRANT ALL PRIVILEGES ON DATABASE postgreDB TO kinou;
EOSQL

View File

@ -1,19 +1,24 @@
ALTER USER postgres WITH PASSWORD 'pass';
-- DROP DATABASE IF EXISTS test;
-- CREATE DATABASE postgreDB;
-- -- CREATE USER IF NOT EXISTS '$POSTGRES_USER'@'%' IDENTIFIED BY 'POSTGRES_PASSWORD';
-- CREATE USER "$POSTGRES_USER" WITH PASSWORD '$POSTGRES_PASSWORD';
-- CREATE USER root WITH PASSWORD '$POSTGRES_ROOT_PASSWORD';
DROP DATABASE IF EXISTS test;
CREATE DATABASE postgreDB;
CREATE USER IF NOT EXISTS '$POSTGRES_USER'@'%' IDENTIFIED BY 'POSTGRES_PASSWORD';
GRANT ALL PRIVILEGES ON *.* TO '$POSTGRES_USER'@'%';
SET PASSWORD FOR 'root'@'$POSTGRES_HOST' = PASSWORD('POSTGRES_ROOT_PASSWORD');
-- -- GRANT ALL PRIVILEGES ON *.* TO '$POSTGRES_USER'@'%';
-- GRANT ALL PRIVILEGES ON DATABASE postgreDB TO "$POSTGRES_USER";
-- -- SET PASSWORD FOR 'root'@'$POSTGRES_HOST' = PASSWORD('$POSTGRES_ROOT_PASSWORD');
-- -- ALTER USER root WITH PASSWORD '$POSTGRES_ROOT_PASSWORD';
FLUSH PRIVILEGES;
CREATE TABLE user (
nickname varchar(20),
user_password varchar(20),
user_login varchar(20)
);
-- -- FLUSH PRIVILEGES;
-- CREATE TABLE users (
-- nickname varchar(20),
-- user_password varchar(20),
-- user_login varchar(20)
-- );
CREATE TABLE score (
win int,
loose int
);
-- CREATE TABLE score (
-- win int,
-- loose int
-- );

View File

@ -15,43 +15,64 @@ services:
# - 443:443
volumes:
- ./frontend:/var/www/html
restart: unless-stopped
# restart: unless-stopped
networks:
- pongNetwork
backend:
image: node:latest
build:
context : ./
dockerfile: ./dockerfiles/Dockerfile.backEnd
container_name: backend
ports:
- 5000:5000
- 3000:3000
env_file: .env
volumes:
- ./frontend:/var/www/html
# volumes:
# - ./backend:/home/node/app
# - ./backend:/usr/src/app/
depends_on:
- postgresql
restart: unless-stopped
# entrypoint: ["/bin/sh", "-c" , "npm install && npm run start:dev"]
# restart: unless-stopped
networks:
- pongNetwork
postgresql:
build: #./dockerfiles/Dockerfile.PostgreSQL
context : ./
dockerfile: ./dockerfiles/Dockerfile.PostgreSQL
container_name: postgresql
#image: mariadb:homemade
image: postgres:14.1-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- 5432:5432
# - ${POSTGRES_PORT}:${POSTGRES_PORT}
env_file: .env
#volumes:
# - dbdata:/var/lib/mysql
volumes:
- db:/var/lib/postgresql/data
- ./database/init.sql:/docker-entrypoint-initdb.d/create_tables.sql
networks:
- pongNetwork
restart: unless-stopped
# postgresql:
# build: #./dockerfiles/Dockerfile.PostgreSQL
# context : ./
# dockerfile: ./dockerfiles/Dockerfile.PostgreSQL
# container_name: postgreDB
# #image: mariadb:homemade
# ports:
# - 5432:5432
# # - ${POSTGRES_PORT}:${POSTGRES_PORT}
# env_file: .env
# # environment:
# # - POSTGRES_USER:kinou
# # - POSTGRES_PASSWORD:pass
# # - POSTGRES_DB:postgreDB
# # - POSTGRES_ROOT_PASSWORD:pass
# # - POSTGRES_HOST:localhost
# # - name:value
# #volumes:
# # - dbdata:/var/lib/mysql
# # networks:
# # - pongNetwork
# restart: unless-stopped
networks:
pongNetwork:
@ -70,6 +91,14 @@ volumes:
type: none
o: 'bind'
device: '/home/apommier/data/mariadb'
back:
driver: local
driver_opts:
type: none
o: 'bind'
device: '/backend'
db:
driver: local
# version: "3.3"
# services:
@ -78,7 +107,7 @@ volumes:
# context: ./dockerfiles
# dockerfile: Dockerfile.backEnd
# ports:
# - "5000:5000"
# - "3000:3000"
# nginx:
# restart: always
# build:

View File

@ -0,0 +1 @@
node_modules

View File

@ -6,12 +6,14 @@
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/19 09:28:30 by apommier #+# #+# #
# Updated: 2023/03/22 18:45:25 by apommier ### ########.fr #
# Updated: 2023/04/07 07:11:27 by apommier ### ########.fr #
# #
# **************************************************************************** #
FROM postgres:latest
FROM postgres:alpine
COPY database/init.sql /docker-entrypoint-initdb.d/
# COPY database/init.sh /docker-entrypoint-initdb.d//init-user-db.sh
# RUN sed -i 's/bind-address/bind-address = 0.0.0.0 #/i' /etc/mysql/mariadb.conf.d/50-server.cnf
EXPOSE 5432
CMD ["postgres"]

View File

@ -6,7 +6,7 @@
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/19 09:28:33 by apommier #+# #+# #
# Updated: 2023/03/22 19:40:22 by apommier ### ########.fr #
# Updated: 2023/04/09 02:16:15 by apommier ### ########.fr #
# #
# **************************************************************************** #
@ -22,16 +22,76 @@
# # RUN npm install express && npm install
# CMD [ "node", "server.js" ]
FROM node:alpine
# FROM node:latest
# FROM node:alpine
# WORKDIR /usr/src/app
# # COPY /backend/* ./
# RUN npm install
# #npm install body-parser
# COPY /backend/ .
# COPY ./.env .
# # RUN rm -rf node_modules
# # EXPOSE 3000
# # RUN curl -o /usr/wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh
# # CMD ["/usr/wait-for-it.sh", "postgresql:5432", "--", "node", "server.js"]
# CMD ["npm", "start"]
# # CMD dockerize -wait tcp://postgresql:5432 -timeout 60s
# # CMD ["node", "app.js"]
# FROM node:alpine
FROM node:latest
RUN apt-get update -y
RUN apt-get install -y postgresql-client
WORKDIR /usr/src/app
COPY /backend/package*.json ./
RUN npm install
COPY ./.env .
#npm install body-parser
COPY /backend/ .
EXPOSE 5000
# RUN curl -o /usr/wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh
# CMD ["/usr/wait-for-it.sh", "postgresql:5432", "--", "node", "server.js"]
COPY /backend/tsconfig*.json ./
# COPY /backend/src ./
COPY /backend/dist /usr/src/app/dist
EXPOSE 3000
# CMD ["npm", "start"]
CMD dockerize -wait tcp://postgresql:5432 -timeout 60s
CMD ["node", "server.js"]
# CMD ["nest", "start", "--watch"]
# CMD ["node", "server.js"]
RUN npm run build
# WORKDIR /usr/src/app/dist
# CMD ["tail", "-f", "/dev/null"]
CMD ["npm", "run", "start:build"]
# CMD ["npm", "run", "start"]
# FROM node:latest
# RUN apt-get update -y
# RUN apt-get install -y postgresql-client
# WORKDIR /usr/src/app
# COPY /backend/package*.json ./
# RUN npm install
# COPY /backend .
# RUN npm run build
# # RUN rm -rf src
# EXPOSE 3000
# RUN rm -rf src
# COPY /backend/package*.json ./dist/
# WORKDIR /usr/src/app/dist
# # RUN ls
# # CMD ["npm", "run", "start"]
# # CMD ["nest", "start"]
# # CMD ["npm", "run", "--prefix", "dist", "start:dev"]
# # CMD ["npm", "run", "start", "&&", "rm", "-rf", "/usr/src/app/src"]
# CMD ["tail", "-f", "/dev/null"]
# # RUN rm -rf /usr/src/app/src

View File

@ -6,12 +6,14 @@
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/19 09:28:32 by apommier #+# #+# #
# Updated: 2023/03/21 11:08:16 by apommier ### ########.fr #
# Updated: 2023/04/07 13:38:20 by apommier ### ########.fr #
# #
# **************************************************************************** #
FROM nginx:latest
RUN apt-get update -y
RUN apt-get install -y postgresql-client
# RUN apt update -y
# RUN apt-get install -y openssl

View File

@ -12,13 +12,6 @@ footer {
background-color: rgb(0, 0, 0);
}
/* #footer {
position:absolute;
bottom:0; /* on le colle en bas */
/* width:100%;
height:100px; */
.pp {
height: 10vh;
width: 10vh;
@ -26,13 +19,10 @@ footer {
}
.loginHere{
/* justify-content: center; */
font-size: 5vh;
font-family: 'Rubik Iso';
text-align: center;
margin-top: 10vh;
/* border: 5px solid rgb(255, 255, 255); */
}
::placeholder {
@ -73,51 +63,27 @@ input{
font-size: 4vh;
max-width: 33%;
color: aqua;
/* text-align: right; */
/* width: 10%; */
justify-content: right;
/* align-self: flex-end; */
/* margin-left: auto; */
/* text-align: right; */
}
label{
/* border: 5px solid rgb(255, 255, 255); */
/* width: 15vw; */
}
.login {
/* text-align: center; */
/* justify-content: center; */
}
.loginForm {
/* margin-top: 20vh; */
align-items: center;
height: 50vh;
/* text-align: center; */
display: flex;
flex-direction: column;
/* border: 5px solid rgb(255, 255, 255); */
justify-content: space-around;
}
/* .menu:hover {
color:blueviolet;
} */
.menu {
color: aqua;
font-size: 4vh;
/* margin-left: %; */
/* padding-left: 2vw; */
/* margin-left: 20px; */
/* max-width: 33%; */
/* margin-right: auto; */
/* align-self: flex-start; */
/* justify-content: start; */
/* text-align: left; */
}
.pong{
@ -125,55 +91,31 @@ label{
}
.box {
/* border: 2px solid white; */
width: 33%;
}
.center {
/* text-align: center; */
align-self: center;
}
.headerName {
/* margin: auto; */
display:flex;
max-width: 33%;
/* align-items: center; */
height: 100%;
font-size: 50px;
/* text-align: center; */
/* align-self: center; */
/* margin: auto; */
/* border: 2px solid white; */
/* height: 100px; */
color:blueviolet;
/* align-items: center; */
/* text-align-last:center; */
font-size: 12vh;
justify-content: center;
}
.header {
display: flex;
/* border: 2px solid white; */
/* border: 5px solid white; */
margin: 0;
height: 15vh;
/* justify-content: space-between; */
align-items: center;
/* justify-content: center; */
/* margin: 0%; */
/* padding: 0% ; */
/* border: 0cap; */
/* width: 100%; */
/* margin-top: 0%; */
/* padding-top: 0%; */
background-color: rgb(0, 0, 0);
/* background-attachment: fixed */
/* color: white; */
}
h1 {
color:blueviolet
/* background-color: rgb(153, 32, 32) !important; */
}

View File

@ -11,40 +11,21 @@
<div class="box menu"> <p class="userTxt">Menu</p> </div>
<div class="box headerName">
<p class="center pong">PONG</p>
<!-- <p class="box headerName">PONG</p> -->
</div>
<div class="box username">
<p class="userTxt">UserName</p>
<img class="pp center" src="./img/pp.jpg" alt="profile picture">
</div>
<!-- <h1 class="headerName">PONG</h1> -->
<!-- <p class="username">username</p> -->
</div>
<div class ="login">
<form id="loginForm" method="post" name="login" action="/api/login" class ="loginForm">
<p class="loginHere">Login Here</p>
<!-- <input type="text" name="prenom"> -->
<!-- <label>Login</label> : -->
<input type="text" name="login" placeholder="login">
<!-- <label>Password</label> : -->
<input type="text" name="password" placeholder="password">
<!-- <input class="submit" type="button" value="LOGIN" onclick="login()"> -->
<button class="submit" onclick="login()">LOGIN</button>
<!-- <script>
function login()
{
alert("Le bouton a été cliqué !");
var formulaire = document.getElementById("loginForm");
formulaire.submit();
}
</script> -->
<!-- <p>Texte à l'intérieur du formulaire</p> -->
</form>
<!-- <p>Texte après le formulaire</p>-->
</div>
<!-- <p>Je suis content de vous accuawdawdeillir sur ma première page web.</p> -->
<footer>
<p>@apommier | apommier@student.42.fr</p>
</footer>