Skip to content

Commit 8eb0671

Browse files
Jaime Salas ZancadaJaime Salas Zancada
authored andcommitted
added exercise applications
1 parent c48ee86 commit 8eb0671

39 files changed

Lines changed: 17371 additions & 0 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Distributed Infrastructure
2+
3+
## Run solutions loacally
4+
5+
Open two terminals, in one of them change directory to `todo-api`, and run `npm start`, in the other terminal change directory to `todo-front`, and run `npm start`
6+
7+
## Run solutions locally using Docker
8+
9+
Start backend
10+
11+
```bash
12+
$ docker run -d -p 3000:3000 \
13+
-e NODE_ENV=production \
14+
-e PORT=3000 \
15+
--name todo-api \
16+
lemoncode/todo-api
17+
```
18+
19+
Start frontend, in order to get connected fron and back, you must build the image as follows `docker build -t lemoncode/todo-front --build-arg API_HOST=http://localhost:3000 .`
20+
21+
```bash
22+
$ docker run -d -p 80:80 --name todo-front lemoncode/todo-front
23+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# local installed dependenies
2+
node_modules/
3+
dist/
4+
5+
# local build
6+
wwwroot/
7+
8+
# local development
9+
nodemon.json
10+
11+
12+
# environment variables
13+
.env
14+
.env.template
15+
.env.test
16+
17+
# tools configuration
18+
.prettierrc
19+
20+
# project info
21+
README.md
22+
23+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=
2+
PORT=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=test
2+
PORT=3001
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"endOfLine": "lf",
5+
"trailingComma": "all",
6+
"singleQuote": true,
7+
"arrowParens": "always"
8+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM node:alpine3.12 as builder
2+
3+
WORKDIR /build
4+
5+
# Copy backend app files
6+
COPY ./src ./src
7+
8+
# Copy dependencies manifest
9+
COPY package*.json ./
10+
11+
# Copy compile configuration
12+
COPY tsconfig.json ./
13+
14+
# Build app
15+
RUN npm install
16+
17+
RUN npm run build
18+
19+
# Packaging app
20+
FROM node:alpine3.12 as app
21+
22+
WORKDIR /app
23+
24+
COPY --from=builder ./build/wwwroot ./
25+
26+
# Install production dependencies
27+
COPY package*.json ./
28+
29+
RUN npm ci --only=production
30+
31+
CMD [ "node", "app.js" ]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Todo App React
2+
3+
## Environment Variables
4+
5+
```ini
6+
NODE_ENV=
7+
PORT=
8+
```
9+
10+
## Running the Application with Docker on Local
11+
12+
```bash
13+
$ docker build -t lemoncode/todo-api .
14+
```
15+
16+
Start app without database
17+
18+
```bash
19+
$ docker run -d -p 3000:3000 \
20+
-e NODE_ENV=production \
21+
-e PORT=3000 \
22+
lemoncode/todo-api
23+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"watch": [
3+
"src"
4+
],
5+
"ext": "ts",
6+
"ignore": [
7+
"src/**/*.spec.ts"
8+
],
9+
"exec": "ts-node ./src/app.ts"
10+
}

0 commit comments

Comments
 (0)