From f5a675229cc37f391ff8709d605de1d72e13d291 Mon Sep 17 00:00:00 2001 From: williben-snhu Date: Mon, 9 May 2022 12:45:50 -0500 Subject: [PATCH 1/5] Adding in everything for Docker --- .dockerignore | 5 +++++ Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..952ff10 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.env +.git +.gitignore +node_modules +npm-debug.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7787ea5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +#using Node v10 +FROM node:10 + +#Create app directory +WORKDIR /usr/src/lafs + +#Install app dependencies +#A wildcard is used to ensure both package.json AND package-lock.json are copied +#where available (npm@5+) +COPY package*.json ./ +RUN npm install -g @angular/cli@v6-lts +RUN npm install +#If you are building your code for production +#RUN npm ci --only=production + +#Bundle app source +COPY . . + +#Expose port 3000 outside container +EXPOSE 4200 +#Command used to start application +CMD ng serve --host 0.0.0.0 \ No newline at end of file From 7f85da2265f784eac720e04c2afdf51993ccddfe Mon Sep 17 00:00:00 2001 From: williben-snhu Date: Mon, 9 May 2022 12:50:40 -0500 Subject: [PATCH 2/5] Adding in everything for Docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7787ea5..ccd9109 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,6 @@ RUN npm install COPY . . #Expose port 3000 outside container -EXPOSE 4200 +EXPOSE 3000 #Command used to start application CMD ng serve --host 0.0.0.0 \ No newline at end of file From 06f495b9eaf5595cc2e902f12d10a188fbf964a2 Mon Sep 17 00:00:00 2001 From: williben-snhu Date: Mon, 9 May 2022 13:33:51 -0500 Subject: [PATCH 3/5] Adding in docker support --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ccd9109..1540f72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,9 @@ WORKDIR /usr/src/lafs #A wildcard is used to ensure both package.json AND package-lock.json are copied #where available (npm@5+) COPY package*.json ./ -RUN npm install -g @angular/cli@v6-lts + +#RUN npm install -g @angular/cli@v6-lts + RUN npm install #If you are building your code for production #RUN npm ci --only=production @@ -19,4 +21,4 @@ COPY . . #Expose port 3000 outside container EXPOSE 3000 #Command used to start application -CMD ng serve --host 0.0.0.0 \ No newline at end of file +CMD npm start -host 0.0.0.0 \ No newline at end of file From f61d51149ee0c9c77d323d413cf73c25ae424bed Mon Sep 17 00:00:00 2001 From: williben-snhu Date: Tue, 10 May 2022 13:00:07 -0500 Subject: [PATCH 4/5] Added in the creation of a network --- docker-compose.yml | 28 ++++++++++++++++++++++++++++ server/datasources.development.js | 10 +++++----- 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cabc4b9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3.7' +services: +# REST API running on Node JS container + app: + container_name: lafs-api + restart: always + build: . + ports: + - '3000:3000' + # link this container to the Mongo DB container + links: + - mongo + # pass in environment variables for database host and name + environment: + - DB_HOST=mongo + - DB_NAME=lafs-db +# Mongo DB storage container + mongo: + container_name: lafs-db + image: 'mongo:4' + ports: + - '27017:27017' +# Attach the external network to these containers +networks: + default: + external: + name: lafs-net + diff --git a/server/datasources.development.js b/server/datasources.development.js index 05c14ba..f3266e4 100644 --- a/server/datasources.development.js +++ b/server/datasources.development.js @@ -1,11 +1,11 @@ module.exports = { mongodb: { connector: 'mongodb', - hostname: process.env.DB_HOST, - port: process.env.DB_PORT, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, + hostname: process.env.DB_HOST || 'localhost', + port: process.env.DB_PORT || 27017, + user: process.env.DB_USER|| '', + password: process.env.DB_PASSWORD || '', + database: process.env.DB_NAME || 'lafs', url: process.env.DB_URL } }; From bb6d006a640fdd6399089e5986398a63f62b20c9 Mon Sep 17 00:00:00 2001 From: williben-snhu Date: Wed, 11 May 2022 00:56:26 -0500 Subject: [PATCH 5/5] Added some changes to the docker file --- Dockerfile | 2 +- docker-compose.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1540f72..02cbedf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,4 +21,4 @@ COPY . . #Expose port 3000 outside container EXPOSE 3000 #Command used to start application -CMD npm start -host 0.0.0.0 \ No newline at end of file +CMD ["node","server/server.js"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cabc4b9..b4d8fea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: build: . ports: - '3000:3000' + depends_on: [mongo] # link this container to the Mongo DB container links: - mongo @@ -19,7 +20,7 @@ services: container_name: lafs-db image: 'mongo:4' ports: - - '27017:27017' + - '27017:27017' # Attach the external network to these containers networks: default: