Skip to content

Commit 5a81cd6

Browse files
committed
ECR images
1 parent abbe997 commit 5a81cd6

File tree

6 files changed

+73
-30
lines changed

6 files changed

+73
-30
lines changed

ansible/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
- name: Build and start application with Docker Compose
101101
become: no
102-
command: docker compose -f docker-compose.yml up -d --build
102+
command: docker compose -f docker-compose.yml up -d --build --remove-orphans
103103
args:
104104
chdir: "{{ app_dir }}"
105105

@@ -109,6 +109,6 @@
109109

110110
- name: Initialize Postgres table
111111
command: docker exec -i postgres psql -U postgres -d movies_db -f /tmp/init.sql
112-
112+
113113

114114

docker-compose.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,24 @@
1212
networks:
1313
- movie-api-network
1414

15-
gateway-frontend:
16-
image: 620914207029.dkr.ecr.eu-west-1.amazonaws.com/movie_api:gateway-frontend
17-
container_name: gateway-frontend
15+
frontend:
16+
image: 620914207029.dkr.ecr.eu-west-1.amazonaws.com/movie_api:frontend
17+
container_name: frontend
18+
expose:
19+
- "8082"
20+
depends_on:
21+
- movieAPI
22+
networks:
23+
- movie-api-network
24+
25+
gateway:
26+
image: 620914207029.dkr.ecr.eu-west-1.amazonaws.com/movie_api:gateway
27+
container_name: gateway
1828
ports:
1929
- "80:80"
2030
depends_on:
2131
- movieAPI
32+
- frontend
2233
networks:
2334
- movie-api-network
2435

frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ COPY script.js /usr/share/nginx/html
55
COPY style.css /usr/share/nginx/html
66

77
COPY nginx.conf /etc/nginx/conf.d/default.conf
8-
EXPOSE 80
8+
EXPOSE 8082
99

1010
CMD ["nginx", "-g", "daemon off;"]

frontend/nginx.conf

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
server {
2-
listen 80;
2+
listen 8082;
33
server_name _;
44

55
root /usr/share/nginx/html;
66
index index.html;
77

8-
9-
10-
location /movie/ {
11-
12-
add_header 'Access-Control-Allow-Origin' '*' always;
13-
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
14-
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization' always;
15-
16-
if ($request_method = OPTIONS) {
17-
add_header 'Access-Control-Allow-Origin' '*';
18-
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
19-
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization';
20-
add_header 'Content-Length' 0;
21-
add_header 'Content-Type' text/plain;
22-
return 204;
23-
}
24-
proxy_pass http://movieAPI:8000/; # backend service inside Docker network
25-
proxy_set_header Host $host;
26-
proxy_set_header X-Real-IP $remote_addr;
27-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28-
proxy_set_header X-Forwarded-Proto $scheme;
29-
}
30-
318
location / {
329
try_files $uri /index.html;
3310
}

gateway/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM nginx:alpine
2+
3+
COPY nginx.conf /etc/nginx/conf.d/default.conf
4+
EXPOSE 80
5+
6+
CMD ["nginx", "-g", "daemon off;"]

gateway/nginx.conf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
6+
7+
8+
9+
location /movie/ {
10+
11+
add_header 'Access-Control-Allow-Origin' '*' always;
12+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
13+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization' always;
14+
15+
if ($request_method = OPTIONS) {
16+
add_header 'Access-Control-Allow-Origin' '*';
17+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
18+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization';
19+
add_header 'Content-Length' 0;
20+
add_header 'Content-Type' text/plain;
21+
return 204;
22+
}
23+
proxy_pass http://movieAPI:8000/; # backend service inside Docker network
24+
proxy_set_header Host $host;
25+
proxy_set_header X-Real-IP $remote_addr;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
proxy_set_header X-Forwarded-Proto $scheme;
28+
}
29+
30+
location / {
31+
add_header 'Access-Control-Allow-Origin' '*' always;
32+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
33+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization' always;
34+
35+
if ($request_method = OPTIONS) {
36+
add_header 'Access-Control-Allow-Origin' '*';
37+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
38+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Authorization';
39+
add_header 'Content-Length' 0;
40+
add_header 'Content-Type' text/plain;
41+
return 204;
42+
}
43+
proxy_pass http://frontend:8082/; # backend service inside Docker network
44+
proxy_set_header Host $host;
45+
proxy_set_header X-Real-IP $remote_addr;
46+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
47+
proxy_set_header X-Forwarded-Proto $scheme;
48+
}
49+
}

0 commit comments

Comments
 (0)