From 265a2edb0241bb6aead37614a04a01000522363d Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Thu, 7 Nov 2024 20:14:01 +0330 Subject: [PATCH 01/18] fixed 404 page not rendering --- src/app/app.routes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 828fa9a..f43a5e2 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -16,4 +16,5 @@ export const routes: Routes = [ { path: 'downloads', title: "Downloads • CodeChef", component: DownloadsComponent }, { path: '**', title: "Not Found • CodeChef", component: NotFoundComponent }, + { path: '404', title: "Not Found • CodeChef", component: NotFoundComponent }, ]; From 4218e1e7b2ecb274b4a43b20452b446a0be8bc6a Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Thu, 7 Nov 2024 20:47:50 +0330 Subject: [PATCH 02/18] added dockerfile and nginx config --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ nginx.conf | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca24d59 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM node:20-alpine AS node-builder + +WORKDIR /app + +COPY public src .editorconfig angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json . + +RUN npm install +RUN npm run build + +FROM python:3.11-alpine AS python-builder + +WORKDIR /app + +RUN apk add --no-cache gcc python3-dev musl-dev libffi-dev libc-dev openssl-dev + +COPY Tools/mssql-proxy . +RUN pip install --no-cache-dir -r requirements.txt pyinstaller +RUN pyinstaller --onefile mssql-proxy.py --name mssql-proxy + +FROM alpine:latest + +RUN apk add --no-cache nginx + +COPY --from=node-builder /app/dist/code-chef /usr/share/nginx/code-chef +COPY --from=python-builder /app/dist/mssql-proxy /usr/local/bin/mssql-proxy + +COPY nginx.conf /etc/nginx/nginx.conf + +RUN mkdir -p /run/nginx /var/log/api + +EXPOSE 80 50505 + +CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..d96a2da --- /dev/null +++ b/nginx.conf @@ -0,0 +1,16 @@ +events {} + +http { + server { + listen 80; + + root /usr/share/nginx/code-chef; + + error_page 404 /usr/share/nginx/code-chef/404 + location = /404{ + internal; + } + + try_files $uri $uri/ /404; + } +} From e1bda455d055c3d7ad8b890429762a996f81fe36 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:21:48 +0000 Subject: [PATCH 03/18] added proxy protocol input to mssql scaffolder --- src/app/mssql-scaffolder/mssql-scaffolder.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.component.ts b/src/app/mssql-scaffolder/mssql-scaffolder.component.ts index 74e4f7d..6960568 100644 --- a/src/app/mssql-scaffolder/mssql-scaffolder.component.ts +++ b/src/app/mssql-scaffolder/mssql-scaffolder.component.ts @@ -40,7 +40,7 @@ import { RouterLink } from '@angular/router'; export class MssqlScaffolderComponent { protected dbSettings: FormGroup = new FormGroup( { - proxy: new FormControl('localhost:50505', { nonNullable: true, validators: [Validators.required] }), + proxy: new FormControl('http://localhost:50505', { nonNullable: true, validators: [Validators.required] }), server: new FormControl('.', { nonNullable: true, validators: [Validators.required] }), username: new FormControl('', { nonNullable: true, validators: [Validators.required] }), password: new FormControl('', { nonNullable: true, validators: [Validators.required] }), @@ -129,7 +129,7 @@ export class MssqlScaffolderComponent { if (this.status == this.connectionStatus.disconnected) { this.status = this.connectionStatus.connecting; this.dbSettings.disable(); - MssqlService.apiUrl = `http://${this.dbSettings.controls["proxy"].value}`; + MssqlService.apiUrl = this.dbSettings.controls["proxy"].value; this.mssql.connect(this.dbSettings.getRawValue() as ConnectRequest).subscribe({ next: (res) => { res = res as ConnectResponse; From 51cd5256cf7d202a0d3187e855317c019150cab0 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:25:37 +0000 Subject: [PATCH 04/18] fixed python and npm layers --- Dockerfile | 7 +++++-- nginx.conf | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca24d59..5c1b4cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,9 @@ FROM node:20-alpine AS node-builder WORKDIR /app -COPY public src .editorconfig angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json . +COPY public public +COPY src src +COPY .editorconfig angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./ RUN npm install RUN npm run build @@ -11,7 +13,8 @@ FROM python:3.11-alpine AS python-builder WORKDIR /app -RUN apk add --no-cache gcc python3-dev musl-dev libffi-dev libc-dev openssl-dev +RUN apk add --no-cache --update alpine-sdk +RUN apk add --no-cache gcc python3-dev musl-dev libffi-dev libc-dev unixodbc unixodbc-dev COPY Tools/mssql-proxy . RUN pip install --no-cache-dir -r requirements.txt pyinstaller diff --git a/nginx.conf b/nginx.conf index d96a2da..e0d5128 100644 --- a/nginx.conf +++ b/nginx.conf @@ -6,7 +6,7 @@ http { root /usr/share/nginx/code-chef; - error_page 404 /usr/share/nginx/code-chef/404 + error_page 404 /usr/share/nginx/code-chef/404; location = /404{ internal; } From 5ee5d18749fd17a4da631802de1a967cceffc718 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:44:22 +0000 Subject: [PATCH 05/18] modified nginx config --- nginx.conf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nginx.conf b/nginx.conf index e0d5128..1818bf9 100644 --- a/nginx.conf +++ b/nginx.conf @@ -4,13 +4,15 @@ http { server { listen 80; - root /usr/share/nginx/code-chef; + root /usr/share/nginx/code-chef/browser; - error_page 404 /usr/share/nginx/code-chef/404; + error_page 404 /usr/share/nginx/code-chef/browser/404; location = /404{ internal; } - try_files $uri $uri/ /404; + location / { + try_files $uri $uri/ /404; + } } } From 628171b5dcf9ac45fa62263e2893884b36bc75e1 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Fri, 8 Nov 2024 09:51:44 +0330 Subject: [PATCH 06/18] removed file from build stage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5c1b4cf..4464623 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /app COPY public public COPY src src -COPY .editorconfig angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./ +COPY angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./ RUN npm install RUN npm run build From 788a5d7c4e0d42e03a9d7b9c6f136edded8bbdd8 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Fri, 8 Nov 2024 15:56:03 +0330 Subject: [PATCH 07/18] cleaned up project structure added dockerignore modified workflows for the new folder structure --- .dockerignore | 17 ++++++++ .github/workflows/build-publish.yml | 24 +++++++---- .github/workflows/build-test.yml | 7 ++++ .gitignore | 22 ---------- Dockerfile | 4 +- .editorconfig => Frontend/.editorconfig | 0 Frontend/.gitignore | 42 +++++++++++++++++++ {.vscode => Frontend/.vscode}/extensions.json | 0 {.vscode => Frontend/.vscode}/launch.json | 0 {.vscode => Frontend/.vscode}/settings.json | 0 {.vscode => Frontend/.vscode}/tasks.json | 0 angular.json => Frontend/angular.json | 0 .../package-lock.json | 0 package.json => Frontend/package.json | 0 {public => Frontend/public}/code-chef.svg | 0 {public => Frontend/public}/ipaf.svg | 0 server.ts => Frontend/server.ts | 0 .../src}/app/app.config.server.ts | 0 {src => Frontend/src}/app/app.config.ts | 0 {src => Frontend/src}/app/app.routes.ts | 0 .../src}/app/app/app.component.html | 0 .../src}/app/app/app.component.spec.ts | 0 .../src}/app/app/app.component.ts | 0 .../app/code-area/code-area.component.css | 0 .../app/code-area/code-area.component.spec.ts | 0 .../src}/app/code-area/code-area.component.ts | 0 .../src}/app/cs2ts/cs2ts.component.html | 0 .../src}/app/cs2ts/cs2ts.component.spec.ts | 0 .../src}/app/cs2ts/cs2ts.component.ts | 0 .../app/downloads/downloads.component.html | 0 .../app/downloads/downloads.component.spec.ts | 0 .../src}/app/downloads/downloads.component.ts | 0 .../src}/app/footer/footer.component.css | 0 .../src}/app/footer/footer.component.html | 0 .../src}/app/footer/footer.component.spec.ts | 0 .../src}/app/footer/footer.component.ts | 0 .../src}/app/header/header.component.css | 0 .../src}/app/header/header.component.html | 0 .../src}/app/header/header.component.spec.ts | 0 .../src}/app/header/header.component.ts | 0 .../src}/app/home/home.component.html | 0 .../src}/app/home/home.component.spec.ts | 0 .../src}/app/home/home.component.ts | 0 .../src}/app/md2html/md2html.component.html | 0 .../app/md2html/md2html.component.spec.ts | 0 .../src}/app/md2html/md2html.component.ts | 0 .../mssql-scaffolder.component.html | 0 .../mssql-scaffolder.component.spec.ts | 0 .../mssql-scaffolder.component.ts | 0 .../mssql-scaffolder.model.ts | 0 .../mssql-scaffolder.service.spec.ts | 0 .../mssql-scaffolder.service.ts | 0 .../app/not-found/not-found.component.css | 0 .../app/not-found/not-found.component.html | 0 .../app/not-found/not-found.component.spec.ts | 0 .../src}/app/not-found/not-found.component.ts | 0 .../serialized-tool.component.html | 0 .../serialized-tool.component.spec.ts | 0 .../serialized-tool.component.ts | 0 {src => Frontend/src}/index.html | 0 {src => Frontend/src}/main.server.ts | 0 {src => Frontend/src}/main.ts | 0 .../src}/services/mssql/mssql.model.ts | 0 .../src}/services/mssql/mssql.service.spec.ts | 0 .../src}/services/mssql/mssql.service.ts | 0 {src => Frontend/src}/styles.css | 0 .../tsconfig.app.json | 0 tsconfig.json => Frontend/tsconfig.json | 0 .../tsconfig.spec.json | 0 Tools/mssql-proxy/.gitignore | 17 ++++++++ 70 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 .dockerignore rename .editorconfig => Frontend/.editorconfig (100%) create mode 100644 Frontend/.gitignore rename {.vscode => Frontend/.vscode}/extensions.json (100%) rename {.vscode => Frontend/.vscode}/launch.json (100%) rename {.vscode => Frontend/.vscode}/settings.json (100%) rename {.vscode => Frontend/.vscode}/tasks.json (100%) rename angular.json => Frontend/angular.json (100%) rename package-lock.json => Frontend/package-lock.json (100%) rename package.json => Frontend/package.json (100%) rename {public => Frontend/public}/code-chef.svg (100%) rename {public => Frontend/public}/ipaf.svg (100%) rename server.ts => Frontend/server.ts (100%) rename {src => Frontend/src}/app/app.config.server.ts (100%) rename {src => Frontend/src}/app/app.config.ts (100%) rename {src => Frontend/src}/app/app.routes.ts (100%) rename {src => Frontend/src}/app/app/app.component.html (100%) rename {src => Frontend/src}/app/app/app.component.spec.ts (100%) rename {src => Frontend/src}/app/app/app.component.ts (100%) rename {src => Frontend/src}/app/code-area/code-area.component.css (100%) rename {src => Frontend/src}/app/code-area/code-area.component.spec.ts (100%) rename {src => Frontend/src}/app/code-area/code-area.component.ts (100%) rename {src => Frontend/src}/app/cs2ts/cs2ts.component.html (100%) rename {src => Frontend/src}/app/cs2ts/cs2ts.component.spec.ts (100%) rename {src => Frontend/src}/app/cs2ts/cs2ts.component.ts (100%) rename {src => Frontend/src}/app/downloads/downloads.component.html (100%) rename {src => Frontend/src}/app/downloads/downloads.component.spec.ts (100%) rename {src => Frontend/src}/app/downloads/downloads.component.ts (100%) rename {src => Frontend/src}/app/footer/footer.component.css (100%) rename {src => Frontend/src}/app/footer/footer.component.html (100%) rename {src => Frontend/src}/app/footer/footer.component.spec.ts (100%) rename {src => Frontend/src}/app/footer/footer.component.ts (100%) rename {src => Frontend/src}/app/header/header.component.css (100%) rename {src => Frontend/src}/app/header/header.component.html (100%) rename {src => Frontend/src}/app/header/header.component.spec.ts (100%) rename {src => Frontend/src}/app/header/header.component.ts (100%) rename {src => Frontend/src}/app/home/home.component.html (100%) rename {src => Frontend/src}/app/home/home.component.spec.ts (100%) rename {src => Frontend/src}/app/home/home.component.ts (100%) rename {src => Frontend/src}/app/md2html/md2html.component.html (100%) rename {src => Frontend/src}/app/md2html/md2html.component.spec.ts (100%) rename {src => Frontend/src}/app/md2html/md2html.component.ts (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.component.html (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.component.spec.ts (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.component.ts (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.model.ts (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.service.spec.ts (100%) rename {src => Frontend/src}/app/mssql-scaffolder/mssql-scaffolder.service.ts (100%) rename {src => Frontend/src}/app/not-found/not-found.component.css (100%) rename {src => Frontend/src}/app/not-found/not-found.component.html (100%) rename {src => Frontend/src}/app/not-found/not-found.component.spec.ts (100%) rename {src => Frontend/src}/app/not-found/not-found.component.ts (100%) rename {src => Frontend/src}/app/serialized-tool/serialized-tool.component.html (100%) rename {src => Frontend/src}/app/serialized-tool/serialized-tool.component.spec.ts (100%) rename {src => Frontend/src}/app/serialized-tool/serialized-tool.component.ts (100%) rename {src => Frontend/src}/index.html (100%) rename {src => Frontend/src}/main.server.ts (100%) rename {src => Frontend/src}/main.ts (100%) rename {src => Frontend/src}/services/mssql/mssql.model.ts (100%) rename {src => Frontend/src}/services/mssql/mssql.service.spec.ts (100%) rename {src => Frontend/src}/services/mssql/mssql.service.ts (100%) rename {src => Frontend/src}/styles.css (100%) rename tsconfig.app.json => Frontend/tsconfig.app.json (100%) rename tsconfig.json => Frontend/tsconfig.json (100%) rename tsconfig.spec.json => Frontend/tsconfig.spec.json (100%) create mode 100644 Tools/mssql-proxy/.gitignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fb7aebf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +.git +.github +.gitignore +LICENSE +README.md + +Tools/mssql-proxy/build +Tools/mssql-proxy/dist +Tools/mssql-proxy/.gitignore +Tools/mssql-proxy/*.spec + +Frontend/.angular +Frontend/.vscode +Frontend/dist +Frontend/node_modules +Frontend/.gitignore +Frontend/.editorconfig \ No newline at end of file diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 19b4cde..60f6a6f 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -10,18 +10,26 @@ permissions: id-token: write jobs: - tests: + build: uses: ./.github/workflows/build-test.yml - deploy: - needs: [tests] + publish: + needs: [build] environment: name: "github-pages" - url: ${{ steps.build-publish.outputs.page_url }} + url: ${{ steps.deploy.outputs.page_url }} runs-on: ubuntu-latest steps: - - id: build-publish - uses: bitovi/github-actions-angular-to-github-pages@v1.0.0 + - name: 'download build' + uses: actions/download-artifact@v4 with: - path: dist/code-chef/browser - build_command: npm run build + name: codechef-build + - name: 'upload pages' + uses: actions/upload-pages-artifact@v3 + with: + path: code-chef/browser + - name: Deploy to GitHub Pages + id: deploy + uses: actions/deploy-pages@v4 + with: + token: ${{ github.token }} diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index dafeda1..9119df0 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,5 +22,12 @@ jobs: with: node-version: ${{ matrix.node }} - run: npm ci + working-directory: Frontend - run: npm run test-ci + working-directory: Frontend - run: npm run build + working-directory: Frontend + - uses: actions/upload-artifact@v4 + with: + name: codechef-build + path: Frontend/dist/code-chef diff --git a/.gitignore b/.gitignore index cc7b141..240d33a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,3 @@ -# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. - -# Compiled output -/dist -/tmp -/out-tsc -/bazel-out - -# Node -/node_modules -npm-debug.log -yarn-error.log - # IDEs and editors .idea/ .project @@ -28,15 +15,6 @@ yarn-error.log !.vscode/extensions.json .history/* -# Miscellaneous -/.angular/cache -.sass-cache/ -/connect.lock -/coverage -/libpeerconnection.log -testem.log -/typings - # System files .DS_Store Thumbs.db diff --git a/Dockerfile b/Dockerfile index 4464623..1309133 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,7 @@ FROM node:20-alpine AS node-builder WORKDIR /app -COPY public public -COPY src src -COPY angular.json package.json package-lock.json server.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./ +COPY Frontend . RUN npm install RUN npm run build diff --git a/.editorconfig b/Frontend/.editorconfig similarity index 100% rename from .editorconfig rename to Frontend/.editorconfig diff --git a/Frontend/.gitignore b/Frontend/.gitignore new file mode 100644 index 0000000..cc7b141 --- /dev/null +++ b/Frontend/.gitignore @@ -0,0 +1,42 @@ +# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. + +# Compiled output +/dist +/tmp +/out-tsc +/bazel-out + +# Node +/node_modules +npm-debug.log +yarn-error.log + +# IDEs and editors +.idea/ +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# Visual Studio Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history/* + +# Miscellaneous +/.angular/cache +.sass-cache/ +/connect.lock +/coverage +/libpeerconnection.log +testem.log +/typings + +# System files +.DS_Store +Thumbs.db diff --git a/.vscode/extensions.json b/Frontend/.vscode/extensions.json similarity index 100% rename from .vscode/extensions.json rename to Frontend/.vscode/extensions.json diff --git a/.vscode/launch.json b/Frontend/.vscode/launch.json similarity index 100% rename from .vscode/launch.json rename to Frontend/.vscode/launch.json diff --git a/.vscode/settings.json b/Frontend/.vscode/settings.json similarity index 100% rename from .vscode/settings.json rename to Frontend/.vscode/settings.json diff --git a/.vscode/tasks.json b/Frontend/.vscode/tasks.json similarity index 100% rename from .vscode/tasks.json rename to Frontend/.vscode/tasks.json diff --git a/angular.json b/Frontend/angular.json similarity index 100% rename from angular.json rename to Frontend/angular.json diff --git a/package-lock.json b/Frontend/package-lock.json similarity index 100% rename from package-lock.json rename to Frontend/package-lock.json diff --git a/package.json b/Frontend/package.json similarity index 100% rename from package.json rename to Frontend/package.json diff --git a/public/code-chef.svg b/Frontend/public/code-chef.svg similarity index 100% rename from public/code-chef.svg rename to Frontend/public/code-chef.svg diff --git a/public/ipaf.svg b/Frontend/public/ipaf.svg similarity index 100% rename from public/ipaf.svg rename to Frontend/public/ipaf.svg diff --git a/server.ts b/Frontend/server.ts similarity index 100% rename from server.ts rename to Frontend/server.ts diff --git a/src/app/app.config.server.ts b/Frontend/src/app/app.config.server.ts similarity index 100% rename from src/app/app.config.server.ts rename to Frontend/src/app/app.config.server.ts diff --git a/src/app/app.config.ts b/Frontend/src/app/app.config.ts similarity index 100% rename from src/app/app.config.ts rename to Frontend/src/app/app.config.ts diff --git a/src/app/app.routes.ts b/Frontend/src/app/app.routes.ts similarity index 100% rename from src/app/app.routes.ts rename to Frontend/src/app/app.routes.ts diff --git a/src/app/app/app.component.html b/Frontend/src/app/app/app.component.html similarity index 100% rename from src/app/app/app.component.html rename to Frontend/src/app/app/app.component.html diff --git a/src/app/app/app.component.spec.ts b/Frontend/src/app/app/app.component.spec.ts similarity index 100% rename from src/app/app/app.component.spec.ts rename to Frontend/src/app/app/app.component.spec.ts diff --git a/src/app/app/app.component.ts b/Frontend/src/app/app/app.component.ts similarity index 100% rename from src/app/app/app.component.ts rename to Frontend/src/app/app/app.component.ts diff --git a/src/app/code-area/code-area.component.css b/Frontend/src/app/code-area/code-area.component.css similarity index 100% rename from src/app/code-area/code-area.component.css rename to Frontend/src/app/code-area/code-area.component.css diff --git a/src/app/code-area/code-area.component.spec.ts b/Frontend/src/app/code-area/code-area.component.spec.ts similarity index 100% rename from src/app/code-area/code-area.component.spec.ts rename to Frontend/src/app/code-area/code-area.component.spec.ts diff --git a/src/app/code-area/code-area.component.ts b/Frontend/src/app/code-area/code-area.component.ts similarity index 100% rename from src/app/code-area/code-area.component.ts rename to Frontend/src/app/code-area/code-area.component.ts diff --git a/src/app/cs2ts/cs2ts.component.html b/Frontend/src/app/cs2ts/cs2ts.component.html similarity index 100% rename from src/app/cs2ts/cs2ts.component.html rename to Frontend/src/app/cs2ts/cs2ts.component.html diff --git a/src/app/cs2ts/cs2ts.component.spec.ts b/Frontend/src/app/cs2ts/cs2ts.component.spec.ts similarity index 100% rename from src/app/cs2ts/cs2ts.component.spec.ts rename to Frontend/src/app/cs2ts/cs2ts.component.spec.ts diff --git a/src/app/cs2ts/cs2ts.component.ts b/Frontend/src/app/cs2ts/cs2ts.component.ts similarity index 100% rename from src/app/cs2ts/cs2ts.component.ts rename to Frontend/src/app/cs2ts/cs2ts.component.ts diff --git a/src/app/downloads/downloads.component.html b/Frontend/src/app/downloads/downloads.component.html similarity index 100% rename from src/app/downloads/downloads.component.html rename to Frontend/src/app/downloads/downloads.component.html diff --git a/src/app/downloads/downloads.component.spec.ts b/Frontend/src/app/downloads/downloads.component.spec.ts similarity index 100% rename from src/app/downloads/downloads.component.spec.ts rename to Frontend/src/app/downloads/downloads.component.spec.ts diff --git a/src/app/downloads/downloads.component.ts b/Frontend/src/app/downloads/downloads.component.ts similarity index 100% rename from src/app/downloads/downloads.component.ts rename to Frontend/src/app/downloads/downloads.component.ts diff --git a/src/app/footer/footer.component.css b/Frontend/src/app/footer/footer.component.css similarity index 100% rename from src/app/footer/footer.component.css rename to Frontend/src/app/footer/footer.component.css diff --git a/src/app/footer/footer.component.html b/Frontend/src/app/footer/footer.component.html similarity index 100% rename from src/app/footer/footer.component.html rename to Frontend/src/app/footer/footer.component.html diff --git a/src/app/footer/footer.component.spec.ts b/Frontend/src/app/footer/footer.component.spec.ts similarity index 100% rename from src/app/footer/footer.component.spec.ts rename to Frontend/src/app/footer/footer.component.spec.ts diff --git a/src/app/footer/footer.component.ts b/Frontend/src/app/footer/footer.component.ts similarity index 100% rename from src/app/footer/footer.component.ts rename to Frontend/src/app/footer/footer.component.ts diff --git a/src/app/header/header.component.css b/Frontend/src/app/header/header.component.css similarity index 100% rename from src/app/header/header.component.css rename to Frontend/src/app/header/header.component.css diff --git a/src/app/header/header.component.html b/Frontend/src/app/header/header.component.html similarity index 100% rename from src/app/header/header.component.html rename to Frontend/src/app/header/header.component.html diff --git a/src/app/header/header.component.spec.ts b/Frontend/src/app/header/header.component.spec.ts similarity index 100% rename from src/app/header/header.component.spec.ts rename to Frontend/src/app/header/header.component.spec.ts diff --git a/src/app/header/header.component.ts b/Frontend/src/app/header/header.component.ts similarity index 100% rename from src/app/header/header.component.ts rename to Frontend/src/app/header/header.component.ts diff --git a/src/app/home/home.component.html b/Frontend/src/app/home/home.component.html similarity index 100% rename from src/app/home/home.component.html rename to Frontend/src/app/home/home.component.html diff --git a/src/app/home/home.component.spec.ts b/Frontend/src/app/home/home.component.spec.ts similarity index 100% rename from src/app/home/home.component.spec.ts rename to Frontend/src/app/home/home.component.spec.ts diff --git a/src/app/home/home.component.ts b/Frontend/src/app/home/home.component.ts similarity index 100% rename from src/app/home/home.component.ts rename to Frontend/src/app/home/home.component.ts diff --git a/src/app/md2html/md2html.component.html b/Frontend/src/app/md2html/md2html.component.html similarity index 100% rename from src/app/md2html/md2html.component.html rename to Frontend/src/app/md2html/md2html.component.html diff --git a/src/app/md2html/md2html.component.spec.ts b/Frontend/src/app/md2html/md2html.component.spec.ts similarity index 100% rename from src/app/md2html/md2html.component.spec.ts rename to Frontend/src/app/md2html/md2html.component.spec.ts diff --git a/src/app/md2html/md2html.component.ts b/Frontend/src/app/md2html/md2html.component.ts similarity index 100% rename from src/app/md2html/md2html.component.ts rename to Frontend/src/app/md2html/md2html.component.ts diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.component.html b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.html similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.component.html rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.html diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.component.spec.ts b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.spec.ts similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.component.spec.ts rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.spec.ts diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.component.ts b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.ts similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.component.ts rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.component.ts diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.model.ts b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.model.ts similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.model.ts rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.model.ts diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.service.spec.ts b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.service.spec.ts similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.service.spec.ts rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.service.spec.ts diff --git a/src/app/mssql-scaffolder/mssql-scaffolder.service.ts b/Frontend/src/app/mssql-scaffolder/mssql-scaffolder.service.ts similarity index 100% rename from src/app/mssql-scaffolder/mssql-scaffolder.service.ts rename to Frontend/src/app/mssql-scaffolder/mssql-scaffolder.service.ts diff --git a/src/app/not-found/not-found.component.css b/Frontend/src/app/not-found/not-found.component.css similarity index 100% rename from src/app/not-found/not-found.component.css rename to Frontend/src/app/not-found/not-found.component.css diff --git a/src/app/not-found/not-found.component.html b/Frontend/src/app/not-found/not-found.component.html similarity index 100% rename from src/app/not-found/not-found.component.html rename to Frontend/src/app/not-found/not-found.component.html diff --git a/src/app/not-found/not-found.component.spec.ts b/Frontend/src/app/not-found/not-found.component.spec.ts similarity index 100% rename from src/app/not-found/not-found.component.spec.ts rename to Frontend/src/app/not-found/not-found.component.spec.ts diff --git a/src/app/not-found/not-found.component.ts b/Frontend/src/app/not-found/not-found.component.ts similarity index 100% rename from src/app/not-found/not-found.component.ts rename to Frontend/src/app/not-found/not-found.component.ts diff --git a/src/app/serialized-tool/serialized-tool.component.html b/Frontend/src/app/serialized-tool/serialized-tool.component.html similarity index 100% rename from src/app/serialized-tool/serialized-tool.component.html rename to Frontend/src/app/serialized-tool/serialized-tool.component.html diff --git a/src/app/serialized-tool/serialized-tool.component.spec.ts b/Frontend/src/app/serialized-tool/serialized-tool.component.spec.ts similarity index 100% rename from src/app/serialized-tool/serialized-tool.component.spec.ts rename to Frontend/src/app/serialized-tool/serialized-tool.component.spec.ts diff --git a/src/app/serialized-tool/serialized-tool.component.ts b/Frontend/src/app/serialized-tool/serialized-tool.component.ts similarity index 100% rename from src/app/serialized-tool/serialized-tool.component.ts rename to Frontend/src/app/serialized-tool/serialized-tool.component.ts diff --git a/src/index.html b/Frontend/src/index.html similarity index 100% rename from src/index.html rename to Frontend/src/index.html diff --git a/src/main.server.ts b/Frontend/src/main.server.ts similarity index 100% rename from src/main.server.ts rename to Frontend/src/main.server.ts diff --git a/src/main.ts b/Frontend/src/main.ts similarity index 100% rename from src/main.ts rename to Frontend/src/main.ts diff --git a/src/services/mssql/mssql.model.ts b/Frontend/src/services/mssql/mssql.model.ts similarity index 100% rename from src/services/mssql/mssql.model.ts rename to Frontend/src/services/mssql/mssql.model.ts diff --git a/src/services/mssql/mssql.service.spec.ts b/Frontend/src/services/mssql/mssql.service.spec.ts similarity index 100% rename from src/services/mssql/mssql.service.spec.ts rename to Frontend/src/services/mssql/mssql.service.spec.ts diff --git a/src/services/mssql/mssql.service.ts b/Frontend/src/services/mssql/mssql.service.ts similarity index 100% rename from src/services/mssql/mssql.service.ts rename to Frontend/src/services/mssql/mssql.service.ts diff --git a/src/styles.css b/Frontend/src/styles.css similarity index 100% rename from src/styles.css rename to Frontend/src/styles.css diff --git a/tsconfig.app.json b/Frontend/tsconfig.app.json similarity index 100% rename from tsconfig.app.json rename to Frontend/tsconfig.app.json diff --git a/tsconfig.json b/Frontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to Frontend/tsconfig.json diff --git a/tsconfig.spec.json b/Frontend/tsconfig.spec.json similarity index 100% rename from tsconfig.spec.json rename to Frontend/tsconfig.spec.json diff --git a/Tools/mssql-proxy/.gitignore b/Tools/mssql-proxy/.gitignore new file mode 100644 index 0000000..24603c8 --- /dev/null +++ b/Tools/mssql-proxy/.gitignore @@ -0,0 +1,17 @@ +# Compiled output +/dist +/build +*.spec + +# IDEs and editors +.idea/ +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# System files +.DS_Store +Thumbs.db From a2a35aabb25e39c252533db73c0a90606a685ccd Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Fri, 8 Nov 2024 17:59:25 +0330 Subject: [PATCH 08/18] modified nginx config (not working) --- Dockerfile | 2 +- nginx.conf | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1309133..e4734e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,6 @@ COPY nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /run/nginx /var/log/api -EXPOSE 80 50505 +EXPOSE 8080 50505 CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy"] diff --git a/nginx.conf b/nginx.conf index 1818bf9..4f29f28 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,17 +2,24 @@ events {} http { server { - listen 80; + listen 0.0.0.0:8080; + listen [::]:8080; + # default_type application/octet-stream; + + # gzip on; + # gzip_comp_level 6; + # gzip_vary on; + # gzip_min_length 1000; + # gzip_proxied any; + # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + # gzip_buffers 16 8k; + # gunzip on; + # client_max_body_size 256M; root /usr/share/nginx/code-chef/browser; - - error_page 404 /usr/share/nginx/code-chef/browser/404; - location = /404{ - internal; - } location / { - try_files $uri $uri/ /404; + try_files $uri $uri/ /index.html =404; } } } From 3ba216858015a9c2b27fd0f7fdda625c8d51cb6c Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 00:54:37 +0330 Subject: [PATCH 09/18] fixed nginx config --- nginx.conf | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/nginx.conf b/nginx.conf index 4f29f28..d95c402 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,25 +1,16 @@ events {} http { - server { - listen 0.0.0.0:8080; - listen [::]:8080; - # default_type application/octet-stream; + include mime.types; - # gzip on; - # gzip_comp_level 6; - # gzip_vary on; - # gzip_min_length 1000; - # gzip_proxied any; - # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; - # gzip_buffers 16 8k; - # gunzip on; - # client_max_body_size 256M; + server { + listen 0.0.0.0:4200; + listen [::]:4200; root /usr/share/nginx/code-chef/browser; location / { - try_files $uri $uri/ /index.html =404; + try_files $uri $uri/ /404/index.html =404; } } } From dffa7132f8a3d8eab63f148b1436fc2d3ddd1fc1 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 08:47:12 +0330 Subject: [PATCH 10/18] added args to mssql-proxy --- Tools/mssql-proxy/mssql-proxy.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Tools/mssql-proxy/mssql-proxy.py b/Tools/mssql-proxy/mssql-proxy.py index 56e588e..30846dd 100644 --- a/Tools/mssql-proxy/mssql-proxy.py +++ b/Tools/mssql-proxy/mssql-proxy.py @@ -1,3 +1,4 @@ +import argparse import pyodbc import uuid from fastapi import FastAPI, HTTPException @@ -9,16 +10,20 @@ # Initialize colorama init(autoreset=True) -from fastapi.middleware.cors import CORSMiddleware +# Argument parsing for port and allowed origin +parser = argparse.ArgumentParser(description="Run the proxy server with customizable port and allowed origin.") +parser.add_argument("--port", "-p", type=int, default=50505, help="Port to run the server on (default: 50505)") +parser.add_argument("--allowed-origin", "-o", type=str, default="http://localhost:4200", help="Allowed CORS origin (default: http://localhost:4200)") +args = parser.parse_args() # Initialize FastAPI app app = FastAPI() +# Set allowed origins origins = [ "https://codechef.ipdotsetaf.ir", "https://ipdotsetaf.github.ir", - "http://localhost:4200" -] + args.allowed_origin] app.add_middleware( CORSMiddleware, @@ -150,4 +155,7 @@ async def disconnect(request: DisconnectRequest): # Run the FastAPI server if __name__ == "__main__": - uvicorn.run(app, host="0.0.0.0", port=50505, access_log=False) + portTxt = f"{Fore.BLUE}{args.port}{Style.RESET_ALL}" + originTxt = f"{Fore.BLUE}{args.allowed_origin}{Style.RESET_ALL}" + print(f"Starting server on port {portTxt} with allowed origin: {originTxt}") + uvicorn.run(app, host="0.0.0.0", port=args.port, access_log=False) \ No newline at end of file From 1e0be040f5ea0b3c8aa593e7fca31af40cb3dfa6 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 09:03:10 +0330 Subject: [PATCH 11/18] added env to dockerfile (needs debugging) --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4734e0..ff4400f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,8 @@ COPY nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /run/nginx /var/log/api -EXPOSE 8080 50505 +EXPOSE 4200 50505 +ENV proxy-port="50505" +ENV allowed-origin="http://localhost:4200" -CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy"] +CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -p ${proxy-port} -o ${allowed-origin}"] From b8ec46fcb03f11c6b45aebbedf383377078dffb1 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 11:55:53 +0330 Subject: [PATCH 12/18] fixed docker file env variables --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff4400f..2eeb5db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,9 @@ COPY nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /run/nginx /var/log/api -EXPOSE 4200 50505 -ENV proxy-port="50505" -ENV allowed-origin="http://localhost:4200" +ENV PROXY_PORT=50505 +ENV ALLOWED_ORIGIN="http://localhost:4200" -CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -p ${proxy-port} -o ${allowed-origin}"] +EXPOSE 4200 $PROXY_PORT + +CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -p ${PROXY_PORT} -o ${ALLOWED_ORIGIN}"] From ac2e6db95af589690900418c29a5d539d5e3bc6f Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 18:25:58 +0330 Subject: [PATCH 13/18] added icons to header buttons --- Frontend/src/app/header/header.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Frontend/src/app/header/header.component.html b/Frontend/src/app/header/header.component.html index 7b8dcb7..b026ab8 100644 --- a/Frontend/src/app/header/header.component.html +++ b/Frontend/src/app/header/header.component.html @@ -12,7 +12,7 @@

CodeChef

- Downloads + Downloads
From e3638ecafbf1149de8e33d13c29da70a660af118 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sat, 9 Nov 2024 18:45:39 +0330 Subject: [PATCH 14/18] updated worflows for docker release --- .github/workflows/build-release.yml | 51 +++++++++++++++++-- .github/workflows/build-test.yml | 2 +- .../{build-publish.yml => publish.yml} | 2 +- 3 files changed, 50 insertions(+), 5 deletions(-) rename .github/workflows/{build-publish.yml => publish.yml} (97%) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index eadcd98..5b682ab 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -1,4 +1,4 @@ -name: Create Release +name: Build Release on: push: @@ -10,9 +10,13 @@ permissions: pages: write id-token: write +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: publish: - uses: ./.github/workflows/build-publish.yml + uses: ./.github/workflows/publish.yml release: needs: [publish, build-linux, build-windows] @@ -67,4 +71,45 @@ jobs: name: build-windows path: mssql-proxy-${{ github.ref_name }}-windows.zip - # build-macos: + # build-macos: + + build-docker-image: + runs-on: linux-latest + steps: + - uses: actions/checkout@v4 + + - name: Install cosign + uses: sigstore/cosign-installer@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Sign the published Docker image + env: + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} \ No newline at end of file diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9119df0..976b218 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,5 +1,5 @@ -name: Build and Test +name: Build Test on: pull_request: diff --git a/.github/workflows/build-publish.yml b/.github/workflows/publish.yml similarity index 97% rename from .github/workflows/build-publish.yml rename to .github/workflows/publish.yml index 60f6a6f..689e0d7 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Create Publish +name: Publish on: workflow_call: From a90dc37a4b72e612a285a0968c0b29845f806874 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 10 Nov 2024 09:05:08 +0330 Subject: [PATCH 15/18] updated readme --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 5c7b8fe..7bda465 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,18 @@ Run `npm run test` or `ng test` to execute the unit tests via [Karma](https://ka ### From precompiled binaries Just download the proper version from the [release section](https://github.com/IPdotSetAF/CodeChef/releases) and run it!! +#### windows +```batch +mssql-proxy.exe +``` +custom port: `-p ` +custom allowed origin: `-o ` + +example: +``` +mssql-proxy.exe -p 50505 -o http://localhost:4200 +``` + ### From Source Code Follow these steps if you want to Run the proxy server from the Python source code: 1. Download the proxy server Python source code from the [release section](https://github.com/IPdotSetAF/CodeChef/releases). From bb109837205b646208c326957dd87f788a04f937 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 10 Nov 2024 13:09:53 +0330 Subject: [PATCH 16/18] updated readme --- README.md | 66 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7bda465..ec07830 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

-# CodeChef +# CodeChef CodeChef is an online developer tool that aims to eliminate repetitive developer tasks and automate what could be automated. @@ -16,15 +16,9 @@ CodeChef is an online developer tool that aims to eliminate repetitive developer - **Serialized tool**
Converts serialized objects between different formats(JSON, XML, YAML, TOML). - **MSSQL Scaffolder**
Scaffolds C# Models from MSSQL Tables and Stored Procedures. -## Usage - You can [**Go to Live Website**](https://codechef.ipdotsetaf.ir) or Run the website locally. -### MSSQL Proxy Server - -If you want to use any of the tools that need to communicate with MSSQL database, you need to download and run the proxy server, you can either download the binaries for your machine from the [**Release**](https://github.com/IPdotSetAF/CodeChef/releases) section or download the proxy [**Source Code**](https://github.com/IPdotSetAF/CodeChef/tree/main/CodeChefDatabaseProxy) and run it in your python environment. - -## Running CodeChef Locally +## Running CodeChef Frontend Locally This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.9. @@ -40,29 +34,57 @@ Run `npm run build` or `ng build` to build the project. The build artifacts will Run `npm run test` or `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). -## Running MSSQL Proxy Server +## MSSQL Proxy Server -### From precompiled binaries -Just download the proper version from the [release section](https://github.com/IPdotSetAF/CodeChef/releases) and run it!! +If you want to use any of the tools that need to communicate with MSSQL database, you need to download and run the proxy server, you can either download the binaries for your machine from the [**Release**](https://github.com/IPdotSetAF/CodeChef/releases) section or download the proxy [**Source Code**](https://github.com/IPdotSetAF/CodeChef/tree/main/CodeChefDatabaseProxy) and run it in your python environment. -#### windows -```batch -mssql-proxy.exe -``` -custom port: `-p ` -custom allowed origin: `-o ` +### Running MSSQL Proxy Server -example: +Just download the proper version from the [release section](https://github.com/IPdotSetAF/CodeChef/releases) and run it!! + +#### Args ``` -mssql-proxy.exe -p 50505 -o http://localhost:4200 +-p --port +-o --allowed-origin ``` -### From Source Code -Follow these steps if you want to Run the proxy server from the Python source code: -1. Download the proxy server Python source code from the [release section](https://github.com/IPdotSetAF/CodeChef/releases). +#### From Source Code +Follow these steps if you want to Run the mssql-proxy from the Python source code: +1. Download the mssql-proxy Python source code from the [release section](https://github.com/IPdotSetAF/CodeChef/releases). 3. `pip install -r requirements.txt` 4. `python proxy.py` +## Docker + +CodeChef docker image contains both the **Frontend** and **mssql-proxy**. + +### Pulling the image +```bash +docker pull ghcr.io/ipdotsetaf/codechef:latest +``` + +### Running the container +```bash +docker run --name codechef -d -p 4200:4200 -p 50505:50505 ghcr.io/ipdotsetaf/codechef:latest +``` + +#### Changing the Frontend port +```bash +docker run --name codechef -d -e ALLOWED_ORIGIN="http://localhost:" -p :4200 -p 50505:50505 ghcr.io/ipdotsetaf/codechef:latest +``` +The allowed origin will be the url that will serve the Fronend and the browser access it with. + +#### Changing the proxy +```bash +docker run --name codechef -d -p 4200:4200 -p :50505 ghcr.io/ipdotsetaf/codechef:latest +``` + +### Exposing database to mssql-proxy +> [!IMPORTANT] +> you need to make sure that codechef container and you mssql-server is on the same network and know the mssql-server ip address exposed on that network. that will be the ip address you use on CodeChef website. +#### Instructions +TBD... + ## TODO: - **Markdown preview** in Markdown to HTML Converter - MSSQL **Diff Tool** From 16875cd458e2575ebf91f9f68d57f7ba1a85696e Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 10 Nov 2024 14:01:50 +0330 Subject: [PATCH 17/18] updated workflows and dockerfile --- .github/workflows/build-release.yml | 6 +++--- .github/workflows/build-test.yml | 1 + Dockerfile | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 5b682ab..fb99b99 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -19,7 +19,7 @@ jobs: uses: ./.github/workflows/publish.yml release: - needs: [publish, build-linux, build-windows] + needs: [publish, build-linux, build-windows, build-docker] runs-on: ubuntu-latest steps: - name: Checkout @@ -73,7 +73,7 @@ jobs: # build-macos: - build-docker-image: + build-docker: runs-on: linux-latest steps: - uses: actions/checkout@v4 @@ -99,7 +99,7 @@ jobs: - name: Build and push Docker image id: build-and-push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . push: true diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 976b218..a851f75 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,6 +28,7 @@ jobs: - run: npm run build working-directory: Frontend - uses: actions/upload-artifact@v4 + if: github.event_name != 'pull_request' with: name: codechef-build path: Frontend/dist/code-chef diff --git a/Dockerfile b/Dockerfile index 2eeb5db..aaecb52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,9 +29,8 @@ COPY nginx.conf /etc/nginx/nginx.conf RUN mkdir -p /run/nginx /var/log/api -ENV PROXY_PORT=50505 ENV ALLOWED_ORIGIN="http://localhost:4200" -EXPOSE 4200 $PROXY_PORT +EXPOSE 4200 50505 -CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -p ${PROXY_PORT} -o ${ALLOWED_ORIGIN}"] +CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -o ${ALLOWED_ORIGIN}"] From 2f088e1573eabf80e7ce698481c16acdc39bdced Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 10 Nov 2024 17:07:30 +0330 Subject: [PATCH 18/18] separated build and push docker image --- .github/workflows/build-release.yml | 53 ++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index fb99b99..cdfb47c 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -39,6 +39,37 @@ jobs: mssql-proxy-${{ github.ref_name }}-linux.tar.gz mssql-proxy-${{ github.ref_name }}-windows.zip + # publish docker + - name: Install cosign + uses: sigstore/cosign-installer@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ needs.build-docker.outputs.tags }} + labels: ${{ needs.build-docker.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Sign the published Docker image + env: + TAGS: ${{ needs.build-docker.outputs.tags }} + DIGEST: ${{ needs.build-docker.outputs.digest }} + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + build-linux: runs-on: ubuntu-latest steps: @@ -75,22 +106,16 @@ jobs: build-docker: runs-on: linux-latest + outputs: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + digest: ${{ steps.build-and-push.outputs.digest }} steps: - uses: actions/checkout@v4 - - name: Install cosign - uses: sigstore/cosign-installer@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract Docker metadata uses: docker/metadata-action@v5 id: meta @@ -102,14 +127,8 @@ jobs: uses: docker/build-push-action@v6 with: context: . - push: true + push: false tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - - - name: Sign the published Docker image - env: - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} \ No newline at end of file