Skip to content

Commit 06eff55

Browse files
committed
Added: docker compose and files
1 parent d88e18a commit 06eff55

File tree

7 files changed

+195
-0
lines changed

7 files changed

+195
-0
lines changed

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:lts AS build
2+
3+
LABEL maintainer="Arvind .A"
4+
LABEL email="pingarvindforquestions@gmail.com"
5+
6+
WORKDIR /app
7+
8+
COPY . .
9+
10+
RUN npm install pnpm -g && \
11+
ls -la && \
12+
cd src/ui && \
13+
pnpm install && \
14+
pnpm collect
15+
16+
FROM python:3.10-slim AS dev
17+
18+
ENV PYTHONUNBUFFERED=1
19+
ENV PYTHONDONTWRITEBYTECODE=1
20+
21+
COPY --from=build /app /app
22+
23+
WORKDIR /app
24+
25+
RUN python3 -m venv /opt/venv && \
26+
/opt/venv/bin/pip install pip --upgrade && \
27+
/opt/venv/bin/pip install -r /app/src/requirements.txt && \
28+
chmod +x /app/src/commands/run-prod.sh && \
29+
chmod +x /app/src/commands/docker-entrypoint.sh
30+
31+
FROM python:3.10-slim AS prod
32+
33+
ENV PYTHONUNBUFFERED=1
34+
ENV PYTHONDONTWRITEBYTECODE=1
35+
36+
COPY --from=dev /app /app
37+
COPY --from=dev /opt/venv /opt/venv
38+
39+
WORKDIR /app
40+
41+
ENTRYPOINT [ "/app/src/commands/docker-entrypoint.sh" ]
42+
CMD ["/app/src/commands/run-prod.sh"]

backend.Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.10-slim AS dev
2+
3+
LABEL maintainer="Arvind .A"
4+
LABEL email="pingarvindforquestions@gmail.com"
5+
6+
WORKDIR /app
7+
8+
ENV PYTHONUNBUFFERED=1
9+
ENV PYTHONDONTWRITEBYTECODE=1
10+
11+
COPY . .
12+
13+
WORKDIR /app
14+
15+
RUN python3 -m venv /opt/venv && \
16+
/opt/venv/bin/pip install pip --upgrade && \
17+
/opt/venv/bin/pip install -r /app/src/requirements.txt && \
18+
chmod +x /app/src/commands/run-prod.sh && \
19+
chmod +x /app/src/commands/docker-entrypoint.sh
20+
21+
FROM python:3.10-slim AS prod
22+
23+
ENV PYTHONUNBUFFERED=1
24+
ENV PYTHONDONTWRITEBYTECODE=1
25+
26+
COPY --from=dev /app /app
27+
COPY --from=dev /opt/venv /opt/venv
28+
29+
WORKDIR /app
30+
31+
ENTRYPOINT [ "/app/src/commands/docker-entrypoint.sh" ]
32+
CMD ["/app/src/commands/run-prod.sh"]

compose.nginx.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: '3'
2+
3+
services:
4+
backend:
5+
container_name: django-backend
6+
build:
7+
context: .
8+
dockerfile: backend.Dockerfile
9+
ports:
10+
- "8888:8000"
11+
env_file:
12+
- .env
13+
environment:
14+
- DJANGO_IN_REACT=0
15+
16+
frontend:
17+
container_name: react-frontend
18+
build:
19+
context: .
20+
dockerfile: frontend.Dockerfile
21+
ports:
22+
- "3333:3000"
23+
24+
nginx:
25+
container_name: nginx
26+
build:
27+
context: .
28+
dockerfile: nginx.Dockerfile
29+
volumes:
30+
- static:/app/static-cdn-local/
31+
ports:
32+
- 80:80
33+
- 443:443
34+
depends_on:
35+
- backend
36+
- frontend
37+
38+
volumes:
39+
static:

compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
container_name: app
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
ports:
10+
- "8080:8000"
11+
env_file:
12+
- .env

frontend.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:lts AS build
2+
3+
LABEL maintainer="Arvind .A"
4+
LABEL email="pingarvindforquestions@gmail.com"
5+
6+
WORKDIR /ui
7+
8+
COPY . .
9+
10+
RUN npm install pnpm -g && \
11+
cd src/ui && \
12+
pnpm install && \
13+
pnpm build:standlone
14+
15+
FROM node:lts AS prod
16+
17+
COPY --from=build /ui/src/ui/dist /ui/dist
18+
19+
RUN npm install -g serve
20+
21+
CMD [ "serve", "-s", "/ui/dist", "-l", "3000"]

nginx.Dockerfile

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

nginx.conf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
upstream frontend_server {
2+
server frontend:3000;
3+
}
4+
5+
upstream backend_server {
6+
server backend:8000;
7+
}
8+
9+
server {
10+
listen 80;
11+
server_name 0.0.0.0;
12+
13+
root /usr/share/nginx/html;
14+
include /etc/nginx/mime.types;
15+
16+
server_tokens off;
17+
18+
proxy_http_version 1.1;
19+
proxy_set_header Upgrade $http_upgrade;
20+
proxy_set_header Connection 'upgrade';
21+
proxy_set_header Host $host;
22+
proxy_cache_bypass $http_upgrade;
23+
24+
location / {
25+
proxy_pass http://frontend_server;
26+
}
27+
28+
location /api/ {
29+
proxy_pass http://backend_server/api/;
30+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31+
proxy_set_header Host $host;
32+
proxy_redirect off;
33+
proxy_connect_timeout 70s;
34+
proxy_send_timeout 86400;
35+
proxy_read_timeout 86400;
36+
send_timeout 86400;
37+
}
38+
39+
location ^~ /static/ {
40+
proxy_pass http://backend_server/static/;
41+
}
42+
}

0 commit comments

Comments
 (0)