Skip to content

Commit

Permalink
Merge pull request #108 from WildCodeSchool/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
LuckyShuii authored Jan 27, 2025
2 parents 4ef62d0 + 91e25ee commit 955af1b
Show file tree
Hide file tree
Showing 123 changed files with 26,105 additions and 0 deletions.
Empty file added .dockerignore
Empty file.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JWT_SECRET_KEY=mykey
FRONTEND_URL=myfrontendurl
32 changes: 32 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: jest-and-docker-ci

on: push

jobs:
test-front:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Goto frontend and run tests
run: cd frontend && npm i && npm test

test-back:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Copy production env file
run: echo "${{ secrets.PRODUCTION_ENV_FILE }}" > .env
- name: Goto backend and run tests
run: cd backend && npm i && npm test

test-e2e:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Copy production env file
run: echo "${{ secrets.PRODUCTION_ENV_FILE }}" > .env
- name: Goto e2e and run tests
run: docker compose -f docker-compose.e2e.yml up --build --exit-code-from e2e
44 changes: 44 additions & 0 deletions .github/workflows/client-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/staging-server.yml
name: Compile and push client image

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: ["develop"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# login with Docker
- uses: docker/login-action@v1
name: Login to Docker Hub
with:
# generate some credentials from Dockerhub and store them into the repo secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# prepare buildx for docker
- uses: docker/setup-buildx-action@v1
name: Set up Docker Buildx

# build an push the newly created image
- uses: docker/build-push-action@v2
name: Build and push client
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_HUB_CLIENT_IMAGE_NAME }}:latest
44 changes: 44 additions & 0 deletions .github/workflows/files-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/staging-server.yml
name: Compile and push files image

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ "develop" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# login with Docker
- uses: docker/login-action@v1
name: Login to Docker Hub
with:
# generate some credentials from Dockerhub and store them into the repo secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# prepare buildx for docker
- uses: docker/setup-buildx-action@v1
name: Set up Docker Buildx

# build an push the newly created image
- uses: docker/build-push-action@v2
name: Build and push client
with:
context: ./files
file: ./files/Dockerfile.prod
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_HUB_FILES_IMAGE_NAME }}:latest
44 changes: 44 additions & 0 deletions .github/workflows/server-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/staging-server.yml
name: Compile and push server image

# Controls when the workflow will run !
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: ["develop"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# login with Docker
- uses: docker/login-action@v1
name: Login to Docker Hub
with:
# generate some credentials from Dockerhub and store them into the repo secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# prepare buildx for docker
- uses: docker/setup-buildx-action@v1
name: Set up Docker Buildx

# build an push the newly created image
- uses: docker/build-push-action@v2
name: Build and push server
with:
context: ./backend
file: ./backend/Dockerfile.prod
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_HUB_SERVER_IMAGE_NAME }}:latest
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
postgres-data/
/files/src/.env
/files/node_modules/
/node_modules/
node_modules/
.idea/
.DS_Store
.env
/frontend/package-lock.json
25 changes: 25 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/.env
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts-alpine3.18

WORKDIR /app

RUN apk --no-cache add curl

COPY package.json package.json
RUN npm install loglevel --verbose

COPY tsconfig.json tsconfig.json

COPY src src
COPY migrations migrations

CMD npm start
27 changes: 27 additions & 0 deletions backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:lts-alpine as builder

WORKDIR /app

COPY tsconfig.json tsconfig.json
COPY package.json package.json

RUN npm install
RUN npm install -g typescript

COPY src src

RUN tsc

FROM node:lts-alpine

RUN apk --no-cache add curl

WORKDIR /app

COPY --from=builder /app/dist /app/dist

COPY package.json package.json

RUN npm install --production

CMD npm run startprod
7 changes: 7 additions & 0 deletions backend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
},
};
13 changes: 13 additions & 0 deletions backend/migrations/1738003402115-CreateMigrationTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
import { MigrationInterface, QueryRunner } from "typeorm";
export class CreateMigrationTest1738003402115 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}
*/
14 changes: 14 additions & 0 deletions backend/migrations/1738006098202-testGenerateMigration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class TestGenerateMigration1738006098202 implements MigrationInterface {
name = 'TestGenerateMigration1738006098202'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "billing" ADD "test" character varying`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "billing" DROP COLUMN "test"`);
}

}
Loading

0 comments on commit 955af1b

Please sign in to comment.