Skip to content

Commit

Permalink
added https certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
sahalali committed Apr 19, 2024
1 parent faa57b7 commit 61c05d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-to-test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
Expand All @@ -66,5 +67,5 @@ jobs:

run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.PAT }} && docker pull ghcr.io/${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main && docker images && docker ps -q --filter name=artsdata-reconciliation | xargs -r docker rm -f && docker run -itd --restart always -p 3000:3000 --name artsdata-reconciliation ghcr.io/${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main && docker image prune -a -f'
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.PAT }} && docker pull ghcr.io/${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main && docker images && docker ps -q --filter name=artsdata-reconciliation | xargs -r docker rm -f && docker run -itd --restart always -p 3000:3000 --name artsdata-reconciliation ghcr.io/${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main && docker image prune -a -f && docker cp ./secrets artsdata-reconciliation:./usr/src/app/secrets'
5 changes: 5 additions & 0 deletions src/config/system.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ const { env } = process;
export const ARTSDATA: { ENDPOINT: string } = {
ENDPOINT: env.ARTSDATA_ENDPOINT || "https://db.artsdata.ca/"
};

export const APPLICATION = {
HTTP_PORT: Number(env.APP_PORT) || 3000,
HTTPS_PORT: Number(env.APP_PORT) || 3000
};
24 changes: 22 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { ExpressAdapter } from "@nestjs/platform-express";
import { AppModule } from "./app.module";
import { APPLICATION } from "./config/system.config";
import * as express from "express";
import * as fs from "fs";
import * as http from "http";
import * as https from "https";



async function bootstrap() {
const app = await NestFactory.create(AppModule);
const httpsOptions = {
key: fs.readFileSync("./secrets/private-key.pem"),
cert: fs.readFileSync("./secrets/public-certificate.pem")
};

const server = express();
const app = await NestFactory.create(
AppModule,
new ExpressAdapter(server)
);

const config = new DocumentBuilder()
.setTitle("Artsdata.ca Reconciliation Service")
Expand All @@ -13,7 +30,10 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("api", app, document);

await app.listen(3000);
await app.init();
// http.createServer(server).listen(APPLICATION.HTTP_PORT);
https.createServer(httpsOptions, server).listen(APPLICATION.HTTPS_PORT);

}

bootstrap();

0 comments on commit 61c05d2

Please sign in to comment.