Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18 docker #20

Merged
merged 19 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
27 changes: 0 additions & 27 deletions .github/workflows/build-publish.yml

This file was deleted.

72 changes: 68 additions & 4 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Release
name: Build Release

on:
push:
Expand All @@ -10,12 +10,16 @@ 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]
needs: [publish, build-linux, build-windows, build-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -35,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:
Expand Down Expand Up @@ -67,4 +102,33 @@ jobs:
name: build-windows
path: mssql-proxy-${{ github.ref_name }}-windows.zip

# build-macos:
# build-macos:

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: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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@v6
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 9 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

name: Build and Test
name: Build Test

on:
pull_request:
Expand All @@ -22,5 +22,13 @@ 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
if: github.event_name != 'pull_request'
with:
name: codechef-build
path: Frontend/dist/code-chef
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
uses: ./.github/workflows/build-test.yml

publish:
needs: [build]
environment:
name: "github-pages"
url: ${{ steps.deploy.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: 'download build'
uses: actions/download-artifact@v4
with:
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 }}
22 changes: 0 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM node:20-alpine AS node-builder

WORKDIR /app

COPY Frontend .

RUN npm install
RUN npm run build

FROM python:3.11-alpine AS python-builder

WORKDIR /app

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
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

ENV ALLOWED_ORIGIN="http://localhost:4200"

EXPOSE 4200 50505

CMD ["sh", "-c", "nginx && /usr/local/bin/mssql-proxy -o ${ALLOWED_ORIGIN}"]
File renamed without changes.
42 changes: 42 additions & 0 deletions Frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/app/app.routes.ts → Frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
];
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1 class="fs-3 m-0">CodeChef</h1>
<div class="dropdown">
<a class="btn btn-header btn-hover dropdown-toggle rounded-0" role="button" id="dropdownMenuLink"
data-bs-toggle="dropdown" aria-expanded="false">
Tools
<i class="bi bi-tools"></i> Tools
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<li><a class="dropdown-item" [routerLink]="['/cs2ts']">C# to TS Converter</a></li>
Expand All @@ -21,7 +21,7 @@ <h1 class="fs-3 m-0">CodeChef</h1>
<li><a class="dropdown-item" [routerLink]="['/mssqlscaffold']">MSSQL Scaffolder</a></li>
</ul>
</div>
<a class="btn-header btn-hover" [routerLink]="['/downloads']">Downloads</a>
<a class="btn-header btn-hover" [routerLink]="['/downloads']"><i class="bi bi-download"></i> Downloads</a>
</div>

<div class="col-4 h-100 d-flex align-items-center justify-content-end p-2 gap-2">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { RouterLink } from '@angular/router';
export class MssqlScaffolderComponent {
protected dbSettings: FormGroup = new FormGroup<DbSetting>(
{
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] }),
Expand Down Expand Up @@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading