Skip to content

Commit 8d7e79d

Browse files
authored
Merge pull request #36 from ThomasOliver545/2022/dockerize
2022/dockerize
2 parents d1f9b1d + 9cd567b commit 8d7e79d

File tree

34 files changed

+167
-14
lines changed

34 files changed

+167
-14
lines changed
File renamed without changes.

README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
If you are coming from a specific video, you can have a look at the commits, they are named like: 'video-01: asd', 'video-02: asd', so you can switch to a commit/merge commit and see what exactly had been done, since this repo is currently evolving and sometimes parts of it are rewritten in newer videos.
2+
Hint: Upon 2022 the new features are not prefixed like this anymore (cause there isn't a video for every step anymore).
23

3-
# instructions to run the project
4-
## 1. Switch to branch develop to get the latest changes
5-
## 2. Add an environment file to the project
4+
# Updated 2022 (Project now dockerized)
5+
This Project is now dockerized.
6+
We have one Dockerfile for the api (NestJS) and one for the frontend(Angular).
7+
On the top file level there is a `docker-compose.yml` file that you can start, there is also the database and everything configured. So you don't need to do anything else than run `docker-compose up`.
8+
9+
# Instructions to run the Project
10+
11+
## With Docker
12+
Command:
13+
`docker-compose up`
14+
and then visit `localhost:4200`
15+
16+
### Tipps & Tricks for docker
17+
If you need to remove docker images or containers you can use one of the following commands.
18+
19+
Command to remove all images:
20+
`docker rmi -f $(docker images -a -q)`
21+
22+
Command to remove all containers:
23+
`docker rm -vf $(docker ps -a -q)`
24+
25+
26+
## Without Docker
27+
### 2. Add an environment file to the project
628
Add a .env file in the api folder (at the top of your api folder, so nest can find it)
729
- add your own DATABASE_URL in the .env file
830
- add your own JWT_SECRET in the .env file
@@ -21,17 +43,17 @@ Example of file:
2143
JWT_SECRET=jklasjdoij897231na
2244

2345

24-
## Start the Backend in dev Mode after you added the .env file
46+
### Start the Backend in dev Mode after you added the .env file
2547
`cd api`
2648
`npm install`
2749
`npm run start:dev`
2850

29-
## Start the Frontend in dev Mode after you added the .env file
51+
### Start the Frontend in dev Mode after you added the .env file
3052
`cd frontend`
3153
`npm install`
3254
`ng serve`
3355

34-
## Start the e2e tests
56+
# Start the e2e tests
3557
`cd e2e`
3658
`npm install`
3759
`npm run cypress:open`
@@ -43,9 +65,23 @@ Example of file:
4365
Blog Project only NestJS Videos
4466
https://www.youtube.com/playlist?list=PLVfq1luIZbSnytbsm2i8Ocf_hyUHTsqbZ
4567

46-
4768
Blog Project only Angular Videos
4869
https://www.youtube.com/playlist?list=PLVfq1luIZbSmAWiXmsjUsvdYRu7RdxzaM
4970

5071
Blog Project All Videos
51-
https://www.youtube.com/playlist?list=PLVfq1luIZbSmJIuw_EZVP9mFiMED5fGIn
72+
https://www.youtube.com/playlist?list=PLVfq1luIZbSmJIuw_EZVP9mFiMED5fGIn
73+
74+
Playlist 2022:
75+
<tbd>
76+
77+
# Other Links & Stuff
78+
Link to Github Profile: https://github.com/ThomasOliver545
79+
Link to Youtube Channel: https://www.youtube.com/channel/UCTZMwW4pq_B-o_KkpCtotGw
80+
Link to Twitter: https://twitter.com/Thomas_OliverK
81+
82+
Since i am doing this in my freetime support via
83+
- "Github Sponsor"
84+
- "Github Follow"
85+
- "Youtube Follow"
86+
87+
etc. would be great.

api/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Specify Node Version and Image
2+
# Name Image development (can be anything)
3+
FROM node:14 AS development
4+
5+
# Specify Working directory inside container
6+
WORKDIR /thomas/src/app
7+
8+
# Copy package-lock.json & package.json from host to inside container working directory
9+
COPY package*.json ./
10+
11+
# Install deps inside container
12+
RUN npm install
13+
14+
RUN npm run build
15+
16+
EXPOSE 3000
17+
18+
################
19+
## PRODUCTION ##
20+
################
21+
# Build another image named production
22+
FROM node:14 AS production
23+
24+
ARG NODE_ENV=production
25+
ENV NODE_ENV=${NODE_ENV}
26+
27+
# Set work dir
28+
WORKDIR /thomas/src/app
29+
30+
COPY --from=development /thomas/src/app/ .
31+
32+
EXPOSE 3000
33+
34+
# run app
35+
CMD [ "node", "dist/main"]

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
1313
"start": "nest start",
1414
"start:dev": "nest start --watch",
15-
"start:debug": "nest start --debug --watch",
15+
"start:debug": "nest start --debug 0.0.0.0:9229 --watch",
1616
"start:prod": "node dist/main",
1717
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1818
"test": "jest",
-6.93 KB
Binary file not shown.
-6.93 KB
Binary file not shown.
-6.93 KB
Binary file not shown.
-6.93 KB
Binary file not shown.
-6.93 KB
Binary file not shown.
-6.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)