Skip to content

Commit 4fad01a

Browse files
authored
Add files via upload
1 parent 87ee936 commit 4fad01a

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Dockerfiles/Dockerfile_backend

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM python:3.10
2+
#FROM python:3.10-slim
3+
#install nano text editor in docker container
4+
RUN apt-get update -y && apt-get install nano -y && apt-get install nginx -y && apt-get install -y gunicorn systemd && apt-get install net-tools && apt-get install libmariadb-dev-compat libmariadb-dev
5+
6+
7+
# set environment variables
8+
ENV PYTHONDONTWRITEBYTECODE 1
9+
ENV PYTHONUNBUFFERED 1
10+
11+
12+
# Create directory and sub-directory for project
13+
14+
RUN mkdir -p /app/
15+
16+
# set work directory
17+
WORKDIR /app/
18+
19+
20+
# install dependencies
21+
RUN pip install --upgrade pip && pip install virtualenv
22+
# Create a virtual environment
23+
RUN virtualenv /app/venv
24+
25+
# Set the Python interpreter to the venv's interpreter
26+
ENV PATH="/app/venv/bin:$PATH"
27+
28+
29+
ADD . /app/
30+
31+
32+
# set work directory
33+
WORKDIR /app/backend/
34+
35+
RUN pip install -r requirements.txt
36+
37+
38+
# RUN python manage.py makemigrations --noinput
39+
# RUN python manage.py migrate --noinput
40+
41+
42+
# Create service for gunicorn server. it is possible to start server without create service but we will start, restart and stop gunicorn server using system service.
43+
# RUN cp /app/project-blog/blog/docker/gunicorn/gunicorn.service /etc/systemd/ && cp /app/project-blog/blog/docker/gunicorn/gunicorn.socket /etc/systemd/
44+
#RUN systemctl start gunicorn.socket && systemctl enable gunicorn.socket
45+
46+
# we have not use gunicorn server because gunicorn support only (http) so we have use Daphne only (serves HTTP + WS)
47+
# RUN chmod +x /app/project-blog/backend/docker/backend/entry-point/server-entrypoint.sh
48+
49+
50+
# Simple: Daphne only (serves HTTP + WS)
51+
52+
# entrypoint runs migrations, collectstatic, then Daphne
53+
CMD ["bash", "-lc", "python manage.py migrate --noinput && \
54+
python manage.py collectstatic --noinput || true && \
55+
daphne -b 0.0.0.0 -p 8000 blog.asgi:application"]
56+
EXPOSE 8000
57+

Dockerfiles/Dockerfile_frontend

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -----------------------------------------------------
2+
# Stage 1: Build the React app
3+
# -----------------------------------------------------
4+
FROM node:20.9.0 AS build
5+
6+
# Create directory and sub-directory for project
7+
8+
RUN mkdir -p /app/
9+
10+
# set work directory
11+
WORKDIR /app/
12+
13+
ADD . /app/
14+
15+
# set work directory
16+
WORKDIR /app/frontend/
17+
18+
# Install dependencies
19+
RUN npm install
20+
21+
22+
# # Build the app for production (outputs to /app/build)
23+
# RUN npm run build
24+
25+
26+
27+
# start dev server (keeps container running)
28+
CMD ["npm", "start"]
29+
30+
31+
EXPOSE 3000
32+

0 commit comments

Comments
 (0)