ADD: good set up docker
Some checks failed
/ deploy (push) Failing after 4s

This commit is contained in:
dorian melenotte 2024-10-10 17:28:29 +02:00
parent 5f71dcd028
commit 8f6d6d68a8
15 changed files with 106 additions and 20 deletions

3
.env Normal file
View File

@ -0,0 +1,3 @@
POSTGRES_DB=db
POSTGRES_USER=db
POSTGRES_PASSWORD=db

10
back-end/Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM docker.io/oven/bun:1.1-slim
WORKDIR /app/
COPY package.json bun.lockb .
RUN bun install
COPY api/ api/
COPY index.js .
COPY prisma/ prisma/
COPY .env .
EXPOSE 3000
CMD ["bun", "index.js"]

Binary file not shown.

View File

@ -3,18 +3,18 @@
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest",
"prisma": "5.19.1"
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@prisma/client": "5.19.1",
"@prisma/client": "^5.20.0",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
"cors": "^2.8.5",
"express": "^4.21.0",
"jest": "^29.7.0",
"jsonwebtoken": "^9.0.2",
"supertest": "^7.0.0"
},
"scripts": {

View File

@ -1,10 +0,0 @@
-- CreateTable
CREATE TABLE `User` (
`id` INTEGER NOT NULL,
`username` VARCHAR(191) NOT NULL,
`pswd` VARCHAR(191) NOT NULL,
`email` VARCHAR(191) NOT NULL,
UNIQUE INDEX `User_id_key`(`id`),
UNIQUE INDEX `User_email_key`(`email`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE `User` MODIFY `id` INTEGER NOT NULL AUTO_INCREMENT;

View File

@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"username" TEXT NOT NULL,
"pswd" TEXT NOT NULL,
"email" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

View File

@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "mysql"
provider = "postgresql"

View File

@ -9,7 +9,7 @@ generator client {
}
datasource db {
provider = "mysql"
provider = "postgres"
url = env("DATABASE_URL")
}

View File

@ -1,9 +1,46 @@
---
services:
app:
build: .
front-end:
build: ./front_end
restart: unless-stopped
ports:
- "8000:5173"
environment:
- PROD_URL=${PROD_URL}
depends_on:
- back-end
back-end:
build: ./back-end
restart: unless-stopped
ports:
- "3000:3000"
command:
- sh
- -c
- "bunx prisma migrate deploy && bunx prisma generate && bun index.js"
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_HOST=db
depends_on:
- redis
- db
redis:
image: "valkey/valkey:7"
restart: unless-stopped
db:
image: "postgres:17"
restart: unless-stopped
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
volumes:
- db:/var/lib/postgresql/data
volumes:
db:

View File

@ -0,0 +1,3 @@
export function Profil() {
return <h1>profil page</h1>;
}

View File

@ -25,6 +25,7 @@ export function SignIn() {
const data = await response.json();
alert("Login successful:", data);
//login();
} catch (error) {
console.error("Error during login:", error);
alert("Error during login: " + error.message);

View File

@ -0,0 +1,25 @@
import { createContext, useContext, useState } from "react";
const AuthContext = createContext();
export function AuthProvider({ children }) {
const [isAuthenticated, setIsAuthenticated] = useState(false);
const login = () => {
setIsAuthenticated(true);
};
const logout = () => {
setIsAuthenticated(false);
};
return (
<AuthContext.Provider value={{ isAuthenticated, login, logout }}>
{children}
</AuthContext.Provider>
);
}
export function useAuth() {
return useContext(AuthContext);
}

View File

@ -21,6 +21,12 @@ export const router = createBrowserRouter([
{
path: "/sign-in",
element: <SignIn />,
children: [
{
path: "profil",
/* element: <ProtectedRoute element={<Profil />} />, */
},
],
},
{
path: "/register",