Skip to content

Commit c7664b7

Browse files
committed
Update Docker configuration and health check endpoints to use port 9000
1 parent 840358c commit c7664b7

7 files changed

Lines changed: 142 additions & 56 deletions

File tree

.github/workflows/compose-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
run: |
2727
echo "Checking health..."
2828
for i in {1..10}; do
29-
curl --fail http://0.0.0.0:8000/health && break || sleep 5
29+
curl --fail http://0.0.0.0:9000/health && break || sleep 5
3030
done
31-
curl --fail http://0.0.0.0:8000/health || exit 1
31+
curl --fail http://0.0.0.0:9000/health || exit 1

backend/src/MessagingPlatform.Api/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
var builder = WebApplication.CreateBuilder(args);
1010

11+
builder.WebHost.UseUrls("http://0.0.0.0:9000");
12+
1113
builder.Services.AddEndpointsApiExplorer();
1214
builder.Services.AddSwaggerGen(c =>
1315
{

docker-compose.prod.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# networks:
2+
# dev:
3+
4+
# services:
5+
# db:
6+
# container_name: messagingplatform-db
7+
# image: postgres:15-alpine
8+
# ports:
9+
# - "5432:5432"
10+
# environment:
11+
# POSTGRES_USER: postgres
12+
# POSTGRES_PASSWORD: mysecretpassword
13+
# POSTGRES_DB: postgres
14+
# restart: always
15+
# volumes:
16+
# - messagingplatform-data:/var/lib/postgresql/data
17+
# healthcheck:
18+
# test: ["CMD-SHELL", "pg_isready -U postgres"]
19+
# interval: 10s
20+
# timeout: 5s
21+
# retries: 5
22+
# networks:
23+
# - dev
24+
25+
# backend:
26+
# container_name: messagingplatform-backend
27+
# build:
28+
# context: ./backend
29+
# dockerfile: Dockerfile
30+
# ports:
31+
# - "8080:8080"
32+
# environment:
33+
# ASPNETCORE_ENVIRONMENT: Development
34+
# ConnectionStrings__DefaultConnection: "Host=db;Database=postgres;Username=postgres;Password=mysecretpassword"
35+
# depends_on:
36+
# db:
37+
# condition: service_healthy
38+
# networks:
39+
# - dev
40+
41+
# frontend:
42+
# container_name: messagingplatform-frontend
43+
# build:
44+
# context: ./frontend
45+
# dockerfile: Dockerfile
46+
# ports:
47+
# - "4200:80"
48+
# depends_on:
49+
# db:
50+
# condition: service_healthy
51+
# networks:
52+
# - dev
53+
54+
# volumes:
55+
# messagingplatform-data:

docker-compose.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
networks:
2-
dev:
2+
messagingplatform:
3+
driver: bridge
34

45
services:
5-
db:
6-
container_name: messagingplatform-db
7-
image: postgres:15-alpine
6+
frontend:
7+
container_name: frontend
8+
build:
9+
context: ./frontend
10+
dockerfile: Dockerfile
811
ports:
9-
- "5432:5432"
10-
environment:
11-
POSTGRES_USER: postgres
12-
POSTGRES_PASSWORD: mysecretpassword
13-
POSTGRES_DB: postgres
14-
restart: always
15-
volumes:
16-
- messagingplatform-data:/var/lib/postgresql/data
17-
healthcheck:
18-
test: ["CMD-SHELL", "pg_isready -U postgres"]
19-
interval: 10s
20-
timeout: 5s
21-
retries: 5
12+
- 4200:80
13+
depends_on:
14+
backend:
15+
condition: service_healthy
2216
networks:
23-
- dev
17+
- messagingplatform
2418

2519
backend:
26-
container_name: messagingplatform-backend
20+
container_name: backend
2721
build:
28-
context: ./backend
22+
context: ./backend/src
2923
dockerfile: Dockerfile
3024
ports:
31-
- "8080:8080"
25+
- 9000:9000
3226
environment:
3327
ASPNETCORE_ENVIRONMENT: Development
34-
ConnectionStrings__DefaultConnection: "Host=db;Database=postgres;Username=postgres;Password=mysecretpassword"
28+
ConnectionStrings__DefaultConnection: "Host=postgres;Database=postgres;Username=postgres;Password=mysecretpassword"
3529
depends_on:
36-
db:
30+
postgres:
3731
condition: service_healthy
3832
networks:
39-
- dev
40-
41-
frontend:
42-
container_name: messagingplatform-frontend
43-
build:
44-
context: ./frontend
45-
dockerfile: Dockerfile
33+
- messagingplatform
34+
35+
postgres:
36+
container_name: postgres
37+
image: postgres:15-alpine
4638
ports:
47-
- "4200:80"
48-
depends_on:
49-
db:
50-
condition: service_healthy
39+
- 5432:5432
40+
environment:
41+
POSTGRES_USER: postgres
42+
POSTGRES_PASSWORD: mysecretpassword
43+
restart: always
44+
healthcheck:
45+
test: ["CMD-SHELL", "pg_isready -U postgres"]
46+
interval: 10s
47+
timeout: 5s
48+
retries: 5
49+
volumes:
50+
- postgres-data:/var/lib/postgresql/data
5151
networks:
52-
- dev
52+
- messagingplatform
5353

5454
volumes:
55-
messagingplatform-data:
55+
postgres-data:

frontend/Dockerfile

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
FROM node:20.17.0 as build
1+
ARG ENVIRONMENT=Development
2+
3+
FROM node:20.17.0 AS build
24
WORKDIR /app
5+
36
COPY package*.json ./
47
RUN npm install
8+
59
COPY . .
6-
RUN npm run build --prod
10+
11+
ARG ENVIRONMENT
12+
RUN if [ "$ENVIRONMENT" = "Production" ]; then \
13+
npm run build -- --configuration=production; \
14+
else \
15+
npm run build -- --configuration=development; \
16+
fi
717

818
FROM nginx:1.21.3-alpine
9-
COPY --from=build /app/dist/frontend /usr/share/nginx/html
10-
11-
RUN echo 'server {\
12-
listen 80;\
13-
listen [::]:80;\
14-
server_name localhost;\
15-
location / {\
16-
root /usr/share/nginx/html/browser;\
17-
try_files $uri $uri/ /index.html;\
18-
index index.html index.htm;\
19-
}\
20-
error_page 500 502 503 504 /50x.html;\
21-
location = /50x.html {\
22-
root /usr/share/nginx/html/browser;\
23-
}\
24-
}' > /etc/nginx/conf.d/default.conf
19+
20+
ARG ENVIRONMENT
21+
22+
COPY --from=build /app/dist/web/browser /usr/share/nginx/html
23+
24+
COPY default.conf /etc/nginx/conf.d/default.conf
25+
COPY prod.conf /etc/nginx/conf.d/prod.conf
26+
27+
RUN if [ "$ENVIRONMENT" = "Production" ]; then \
28+
cp /etc/nginx/conf.d/prod.conf /etc/nginx/conf.d/default.conf; \
29+
fi

frontend/default.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
root /usr/share/nginx/html;
6+
7+
index index.html index.htm;
8+
9+
location / {
10+
try_files $uri $uri/ /index.html;
11+
}
12+
}

frontend/prod.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
server {
2+
listen 80;
3+
server_name sentemon.me www.sentemon.me;
4+
5+
root /usr/share/nginx/html;
6+
7+
index index.html index.htm;
8+
9+
location / {
10+
try_files $uri $uri/ /index.html;
11+
}
12+
}

0 commit comments

Comments
 (0)