mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-07-16 00:34:43 +00:00
Set API https
This commit is contained in:
parent
87bfab307d
commit
80056903c6
3 changed files with 14 additions and 7 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import * as fs from 'fs';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { ValidationPipe } from '@nestjs/common';
|
import { ValidationPipe } from '@nestjs/common';
|
||||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
|
|
@ -5,7 +6,13 @@ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
// Use local gen'd cert in container
|
||||||
|
const httpsOptions = {
|
||||||
|
key: fs.readFileSync('/localcert/key.pem', 'utf8'),
|
||||||
|
cert: fs.readFileSync('/localcert/cert.pem', 'utf8')
|
||||||
|
};
|
||||||
|
|
||||||
|
const app = await NestFactory.create(AppModule, { httpsOptions });
|
||||||
|
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
credentials: true
|
credentials: true
|
||||||
|
|
@ -33,6 +40,6 @@ async function bootstrap() {
|
||||||
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
||||||
SwaggerModule.setup('docs', app, document);
|
SwaggerModule.setup('docs', app, document);
|
||||||
|
|
||||||
await app.listen(8080);
|
await app.listen(8443);
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ RUN apk update && apk add --no-cache openssl bash curl
|
||||||
|
|
||||||
# Default envs as prod
|
# Default envs as prod
|
||||||
ENV HOST=0.0.0.0 \
|
ENV HOST=0.0.0.0 \
|
||||||
PORT=8080 \
|
PORT=8443 \
|
||||||
NODE_ENV=production \
|
NODE_ENV=production \
|
||||||
APP_NAME=NestJS
|
APP_NAME=NestJS
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ WORKDIR /opt/node_app
|
||||||
#USER node
|
#USER node
|
||||||
|
|
||||||
# Generate a localhost cert
|
# Generate a localhost cert
|
||||||
# RUN openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout /localcert/key.pem -out /localcert/cert.pem -subj "/C=US/ST=New Jersey/L=Warren/O=localhost/OU=IT/CN=127.0.0.1"
|
RUN openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout /localcert/key.pem -out /localcert/cert.pem -subj "/C=US/ST=New Jersey/L=Warren/O=localhost/OU=IT/CN=127.0.0.1"
|
||||||
|
|
||||||
|
|
||||||
ENV PATH /opt/node_app/node_modules/.bin:$PATH
|
ENV PATH /opt/node_app/node_modules/.bin:$PATH
|
||||||
|
|
@ -62,9 +62,9 @@ COPY ./app/api/package.json ./app/api/package-lock.json* ./
|
||||||
COPY ./build/api/ecosystem._PROD_.config.js /opt/node_app/ecosystem._PROD_.config.js
|
COPY ./build/api/ecosystem._PROD_.config.js /opt/node_app/ecosystem._PROD_.config.js
|
||||||
COPY ./build/api/entrypoint.sh /entrypoint.sh
|
COPY ./build/api/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080 8443
|
||||||
|
|
||||||
HEALTHCHECK --interval=20s --timeout=30s --start-period=5s --retries=5 \
|
HEALTHCHECK --interval=20s --timeout=30s --start-period=5s --retries=5 \
|
||||||
CMD curl -f -k http://localhost:8080/ || exit 1
|
CMD curl -f -k https://localhost:8443/ || exit 1
|
||||||
|
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
|
@ -44,7 +44,7 @@ services:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
|
||||||
api:
|
api:
|
||||||
image: "amineo/t2-stats-api:v0.0.2"
|
image: "amineo/t2-stats-api:v0.0.3"
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./build/api/Dockerfile
|
dockerfile: ./build/api/Dockerfile
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue