Skip to content
Permalink
Browse files

added docker to run in docker with API and Web

added docker to run in docker with API and Web
  • Loading branch information...
ignatandrei committed Aug 22, 2019
1 parent 58e533c commit 6dafb0c0b005d46bc426d128f9caf5d53e039dfa
@@ -1,4 +1,5 @@
.git
node_modules
build
jest-stare
jest-stare
dockerize
@@ -1,12 +1,27 @@
import { Module } from '@nestjs/common';
import { Module, NestModule,MiddlewareConsumer } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MeetingsModule } from './meeting/meeting.module';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';

import { ServeStaticMiddleware } from '@nest-middlewares/serve-static';

@Module({

imports: [MeetingsModule],
imports: [MeetingsModule,
ServeStaticModule
.forRoot({
rootPath: join(__dirname, '..', 'dist','bingo-cards-ui'),
})],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
ServeStaticMiddleware.configure('/test' );
consumer
.apply(ServeStaticMiddleware)
.forRoutes('/test');
}
}
@@ -3,8 +3,9 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
root(): string {
return 'Hello World!';
return 'please access /api or /test for more data!';
}



}
@@ -6,7 +6,7 @@ import { ActualMeeting } from 'bingo-cards-api-objects/src/ActualMeeting';
import { CheckCardParticipant } from 'bingo-cards-api-objects/src/CheckCardParticipant';
import { AddParticipant } from 'bingo-cards-api-objects/src/AddParticipant';

@Controller('meetings')
@Controller('api/meetings')
export class MeetingsController {
constructor(private meetingsService: MeetingService){}

@@ -30,6 +30,38 @@
"scripts": []
},
"configurations": {
"dockerbuild":{

"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dockerbuild.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"preserveSymlinks":true,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
,
"production": {
"fileReplacements": [
{
@@ -5,15 +5,14 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod":"ng build --prod --build-optimizer",
"build:prod": "ng build --prod --build-optimizer",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"build:docker": "ng build --configuration=dockerbuild --build-optimizer"
},
"private": true,
"dependencies": {
"bingo-cards-api-objects":"^1.0.0",
"bingo-meeting-objects": "^1.0.0",
"@angular/animations": "~8.2.0",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
@@ -22,6 +21,11 @@
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@nest-middlewares/serve-static": "^6.0.0",
"@nestjs/serve-static": "^1.0.1",
"bingo-cards-api-objects": "^1.0.0",
"bingo-meeting-objects": "^1.0.0",
"path": "^0.12.7",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
@@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Meeting, ICreateMeeting } from 'bingo-meeting-objects';
import { ActualMeeting } from 'bingo-cards-api-objects';
import { environment } from './../environments/environment';
// import { inject } from '@angular/core/testing';
// import { DOCUMENT } from '@angular/common';

@@ -11,10 +12,11 @@ import { ActualMeeting } from 'bingo-cards-api-objects';
})
export class CardsService {

private urlApi = '//bingo-meeting-api.herokuapp.com/';
private urlApi = '';
// private protocol: string;
constructor(/*@Inject(DOCUMENT)private doc: Document, */ private httpAPI: HttpClient) {
// this.protocol = doc.location.protocol;
this.urlApi= environment.urlApi;
}
public GetMeeting(id: string): Observable<Meeting> {

@@ -0,0 +1,6 @@
export const environment = {
production: true,
urlApi: '/api/'

};
``
@@ -1,3 +1,5 @@
export const environment = {
production: true
production: true,
urlApi:'//bingo-meeting-api.herokuapp.com/api/'

};
@@ -3,7 +3,8 @@
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
production: false,
urlApi:'//bingo-meeting-api.herokuapp.com/api/'
};

/*
@@ -1,6 +1,6 @@
import {Participant} from './Participant';
import {Cards} from './Cards';
import { ok, err, Result, Err } from 'neverthrow';
import { ok, err, Result } from 'neverthrow';
export class Meeting{

constructor(m?:Meeting){
@@ -0,0 +1,3 @@
docker build .. -f docker_runwebapiweb.txt -t bingo_runwebapiweb
docker run --rm -p 3000:3000 --name bingo_runwebapiweb_container bingo_runwebapiweb
docker container kill bingo_runwebapiweb_container
@@ -0,0 +1,18 @@
FROM node:10
WORKDIR /app
COPY package.json ./package.json
COPY bingo-cards-api/package.json ./bingo-cards-api/package.json
COPY bingo-cards-api-objects/package.json ./bingo-cards-api-objects/package.json
COPY bingo-cards-ui/package.json ./bingo-cards-ui/package.json
COPY bingo-meeting-console/package.json ./bingo-meeting-console/package.json
COPY bingo-meeting-objects/package.json ./bingo-meeting-objects/package.json
COPY bingo-meeting-objects-test/package.json ./bingo-meeting-objects-test/package.json

RUN yarn install

COPY . ./
RUN yarn build
RUN yarn build:docker
RUN cp -r ./bingo-cards-ui/dist/ ./bingo-cards-api/
CMD ["yarn","api"]
EXPOSE 3000
@@ -12,7 +12,7 @@
"runConsole": "cd bingo-meeting-console && yarn start",
"buildConsole":"yarn build && cd bingo-meeting-console && yarn build",
"buildWebUI": "cd bingo-cards-ui && yarn build:prod",

"build:docker" :"cd bingo-cards-ui && yarn build:docker",
"build":"tsc -b ."
}
}
@@ -512,6 +512,16 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@nest-middlewares/serve-static@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@nest-middlewares/serve-static/-/serve-static-6.0.0.tgz#be2b2c5b76bf8ed6b6d3131d76abaa7c32441ab7"
integrity sha512-coAqmzwsiIgQSAdpGUE6JbGzt106CKTvx1p/hDwue2e7hCGtCNCNzKbKCZQQPwED1juJn7gZMSFWF6MGa30rbw==
dependencies:
"@types/express" "^4.16.0"
"@types/express-serve-static-core" "^4.16.0"
"@types/serve-static" "^1.13.1"
serve-static "^1.13.1"

"@nestjs/common@6.5.3", "@nestjs/common@^6.5.3":
version "6.5.3"
resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-6.5.3.tgz#25a3916b53f1e681640641bdb96a40bb37a15515"
@@ -543,6 +553,11 @@
express "4.17.1"
multer "1.4.2"

"@nestjs/serve-static@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@nestjs/serve-static/-/serve-static-1.0.1.tgz#0a4494a927d98c3709ab01739d9380cae631f274"
integrity sha512-XAG76ooUSk8EUILl2f56u66/q2I5n8jyEE8j3FwFihtvzMcOQxOyXnhg8Hk/tizRVTExRLFCA7MEijzevxyofw==

"@nestjs/swagger@3.1.0", "@nestjs/swagger@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@nestjs/swagger/-/swagger-3.1.0.tgz#eea2d2ef7416a588e5f122b58cd194884e265dc4"
@@ -703,6 +718,14 @@
"@types/node" "*"
"@types/range-parser" "*"

"@types/express-serve-static-core@^4.16.0":
version "4.16.9"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.16.9.tgz#69e00643b0819b024bdede95ced3ff239bb54558"
integrity sha512-GqpaVWR0DM8FnRUJYKlWgyARoBUAVfRIeVDZQKOttLFp5SmhhF9YFIYeTPwMd/AXfxlP7xVO2dj1fGu0Q+krKQ==
dependencies:
"@types/node" "*"
"@types/range-parser" "*"

"@types/express@^4.16.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.0.tgz#49eaedb209582a86f12ed9b725160f12d04ef287"
@@ -801,6 +824,14 @@
"@types/express-serve-static-core" "*"
"@types/mime" "*"

"@types/serve-static@^1.13.1":
version "1.13.3"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1"
integrity sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g==
dependencies:
"@types/express-serve-static-core" "*"
"@types/mime" "*"

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
@@ -7702,6 +7733,14 @@ path-type@^3.0.0:
dependencies:
pify "^3.0.0"

path@^0.12.7:
version "0.12.7"
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
dependencies:
process "^0.11.1"
util "^0.10.3"

pbkdf2@^3.0.3:
version "3.0.17"
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6"
@@ -7928,7 +7967,7 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==

process@^0.11.10:
process@^0.11.1, process@^0.11.10:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
@@ -8821,7 +8860,7 @@ serve-index@^1.9.1:
mime-types "~2.1.17"
parseurl "~1.3.2"

serve-static@1.14.1:
serve-static@1.14.1, serve-static@^1.13.1:
version "1.14.1"
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9"
integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
@@ -10225,6 +10264,13 @@ util@0.10.3:
dependencies:
inherits "2.0.1"

util@^0.10.3:
version "0.10.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
dependencies:
inherits "2.0.3"

util@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/util/-/util-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61"

0 comments on commit 6dafb0c

Please sign in to comment.
You can’t perform that action at this time.