diff --git a/.gitignore b/.gitignore index 651db82..0afa4f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/node_modules *.pyc **/__pycache__ +**/postgres_data diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..dacce5b --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.11.3 +WORKDIR /app +ENV PYTHONBUFFERED=1 +COPY requirements.txt /app +RUN pip install -r requirements.txt --no-cache-dir +COPY /app /app +ENTRYPOINT ["python"] +CMD ["manage.py", "runserver", "0.0.0.0:8000"] diff --git a/backend/backend/__init__.py b/api/app/backend/__init__.py similarity index 100% rename from backend/backend/__init__.py rename to api/app/backend/__init__.py diff --git a/backend/backend/asgi.py b/api/app/backend/asgi.py similarity index 100% rename from backend/backend/asgi.py rename to api/app/backend/asgi.py diff --git a/backend/backend/settings.py b/api/app/backend/settings.py similarity index 100% rename from backend/backend/settings.py rename to api/app/backend/settings.py diff --git a/backend/backend/urls.py b/api/app/backend/urls.py similarity index 100% rename from backend/backend/urls.py rename to api/app/backend/urls.py diff --git a/backend/backend/wsgi.py b/api/app/backend/wsgi.py similarity index 100% rename from backend/backend/wsgi.py rename to api/app/backend/wsgi.py diff --git a/backend/custom_auth/__init__.py b/api/app/custom_auth/__init__.py similarity index 100% rename from backend/custom_auth/__init__.py rename to api/app/custom_auth/__init__.py diff --git a/backend/custom_auth/admin.py b/api/app/custom_auth/admin.py similarity index 100% rename from backend/custom_auth/admin.py rename to api/app/custom_auth/admin.py diff --git a/backend/custom_auth/apps.py b/api/app/custom_auth/apps.py similarity index 100% rename from backend/custom_auth/apps.py rename to api/app/custom_auth/apps.py diff --git a/backend/custom_auth/migrations/__init__.py b/api/app/custom_auth/migrations/__init__.py similarity index 100% rename from backend/custom_auth/migrations/__init__.py rename to api/app/custom_auth/migrations/__init__.py diff --git a/backend/custom_auth/models.py b/api/app/custom_auth/models.py similarity index 100% rename from backend/custom_auth/models.py rename to api/app/custom_auth/models.py diff --git a/backend/custom_auth/tests.py b/api/app/custom_auth/tests.py similarity index 100% rename from backend/custom_auth/tests.py rename to api/app/custom_auth/tests.py diff --git a/backend/custom_auth/urls.py b/api/app/custom_auth/urls.py similarity index 100% rename from backend/custom_auth/urls.py rename to api/app/custom_auth/urls.py diff --git a/backend/custom_auth/views.py b/api/app/custom_auth/views.py similarity index 100% rename from backend/custom_auth/views.py rename to api/app/custom_auth/views.py diff --git a/backend/db.sqlite3 b/api/app/db.sqlite3 similarity index 100% rename from backend/db.sqlite3 rename to api/app/db.sqlite3 diff --git a/backend/manage.py b/api/app/manage.py similarity index 100% rename from backend/manage.py rename to api/app/manage.py diff --git a/backend/snippets/__init__.py b/api/app/snippets/__init__.py similarity index 100% rename from backend/snippets/__init__.py rename to api/app/snippets/__init__.py diff --git a/backend/snippets/admin.py b/api/app/snippets/admin.py similarity index 100% rename from backend/snippets/admin.py rename to api/app/snippets/admin.py diff --git a/backend/snippets/apps.py b/api/app/snippets/apps.py similarity index 100% rename from backend/snippets/apps.py rename to api/app/snippets/apps.py diff --git a/backend/snippets/migrations/0001_initial.py b/api/app/snippets/migrations/0001_initial.py similarity index 100% rename from backend/snippets/migrations/0001_initial.py rename to api/app/snippets/migrations/0001_initial.py diff --git a/backend/snippets/migrations/__init__.py b/api/app/snippets/migrations/__init__.py similarity index 100% rename from backend/snippets/migrations/__init__.py rename to api/app/snippets/migrations/__init__.py diff --git a/backend/snippets/models.py b/api/app/snippets/models.py similarity index 100% rename from backend/snippets/models.py rename to api/app/snippets/models.py diff --git a/backend/snippets/permissions.py b/api/app/snippets/permissions.py similarity index 100% rename from backend/snippets/permissions.py rename to api/app/snippets/permissions.py diff --git a/backend/snippets/serializers.py b/api/app/snippets/serializers.py similarity index 100% rename from backend/snippets/serializers.py rename to api/app/snippets/serializers.py diff --git a/backend/snippets/tests.py b/api/app/snippets/tests.py similarity index 100% rename from backend/snippets/tests.py rename to api/app/snippets/tests.py diff --git a/backend/snippets/urls.py b/api/app/snippets/urls.py similarity index 100% rename from backend/snippets/urls.py rename to api/app/snippets/urls.py diff --git a/backend/snippets/views.py b/api/app/snippets/views.py similarity index 100% rename from backend/snippets/views.py rename to api/app/snippets/views.py diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 0000000..a92a185 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,3 @@ +django +django-rest-framework +pygments diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..3c6dce6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +services: + api: + build: + context: api + ports: + - "5000" + environment: + - POSTGRES_PASSWORD=password + - POSTGRES_USER=postgres + - POSTGRES_DB=flask + - PYTHONBUFFERED=0 + react: + build: + context: react + ports: + - "3000" + nginx: + image: nginx:1.23.4 + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + - ./static:/static + depends_on: + - api + ports: + - "3000:3000" + postgres: + image: postgres:15.1 + restart: always + volumes: + - ./postgres_data:/var/lib/postgresql/data/ + environment: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: db diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2eb3784 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 3000; + server_name 192.168.1.121; + location / { + proxy_pass http://react:3000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache off; + } + location /api/ { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Headers' '*'; + add_header 'Access-Control-Allow-Methods' '*'; + + proxy_pass http://api:8000/api/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache off; + } +} diff --git a/react/Dockerfile b/react/Dockerfile new file mode 100644 index 0000000..0f65f67 --- /dev/null +++ b/react/Dockerfile @@ -0,0 +1,17 @@ +FROM node:20.1 + +WORKDIR /app +COPY /app /app +# COPY package.json /app/package.json +# COPY package-lock.json /app/package-lock.json + +# Same as npm install +# RUN npm ci + +# COPY . /app +# +ENV CI=true +ENV PORT=3000 +ENV HOST=0.0.0.0 + +CMD [ "npm", "start" ] diff --git a/frontend/.gitignore b/react/app/.gitignore similarity index 100% rename from frontend/.gitignore rename to react/app/.gitignore diff --git a/frontend/README.md b/react/app/README.md similarity index 100% rename from frontend/README.md rename to react/app/README.md diff --git a/frontend/package-lock.json b/react/app/package-lock.json similarity index 100% rename from frontend/package-lock.json rename to react/app/package-lock.json diff --git a/frontend/package.json b/react/app/package.json similarity index 100% rename from frontend/package.json rename to react/app/package.json diff --git a/frontend/public/favicon.ico b/react/app/public/favicon.ico similarity index 100% rename from frontend/public/favicon.ico rename to react/app/public/favicon.ico diff --git a/frontend/public/index.html b/react/app/public/index.html similarity index 100% rename from frontend/public/index.html rename to react/app/public/index.html diff --git a/frontend/public/logo192.png b/react/app/public/logo192.png similarity index 100% rename from frontend/public/logo192.png rename to react/app/public/logo192.png diff --git a/frontend/public/logo512.png b/react/app/public/logo512.png similarity index 100% rename from frontend/public/logo512.png rename to react/app/public/logo512.png diff --git a/frontend/public/manifest.json b/react/app/public/manifest.json similarity index 100% rename from frontend/public/manifest.json rename to react/app/public/manifest.json diff --git a/frontend/public/robots.txt b/react/app/public/robots.txt similarity index 100% rename from frontend/public/robots.txt rename to react/app/public/robots.txt diff --git a/frontend/src/App.css b/react/app/src/App.css similarity index 100% rename from frontend/src/App.css rename to react/app/src/App.css diff --git a/frontend/src/App.js b/react/app/src/App.js similarity index 100% rename from frontend/src/App.js rename to react/app/src/App.js diff --git a/frontend/src/App.test.js b/react/app/src/App.test.js similarity index 100% rename from frontend/src/App.test.js rename to react/app/src/App.test.js diff --git a/frontend/src/components/Header.jsx b/react/app/src/components/Header.jsx similarity index 100% rename from frontend/src/components/Header.jsx rename to react/app/src/components/Header.jsx diff --git a/frontend/src/components/LoginForm.jsx b/react/app/src/components/LoginForm.jsx similarity index 100% rename from frontend/src/components/LoginForm.jsx rename to react/app/src/components/LoginForm.jsx diff --git a/frontend/src/components/MainCard.jsx b/react/app/src/components/MainCard.jsx similarity index 100% rename from frontend/src/components/MainCard.jsx rename to react/app/src/components/MainCard.jsx diff --git a/frontend/src/components/Snippet.jsx b/react/app/src/components/Snippet.jsx similarity index 100% rename from frontend/src/components/Snippet.jsx rename to react/app/src/components/Snippet.jsx diff --git a/frontend/src/context/AuthContext.jsx b/react/app/src/context/AuthContext.jsx similarity index 100% rename from frontend/src/context/AuthContext.jsx rename to react/app/src/context/AuthContext.jsx diff --git a/frontend/src/index.css b/react/app/src/index.css similarity index 100% rename from frontend/src/index.css rename to react/app/src/index.css diff --git a/frontend/src/index.js b/react/app/src/index.js similarity index 100% rename from frontend/src/index.js rename to react/app/src/index.js diff --git a/frontend/src/logo.svg b/react/app/src/logo.svg similarity index 100% rename from frontend/src/logo.svg rename to react/app/src/logo.svg diff --git a/frontend/src/pages/AuthPage.jsx b/react/app/src/pages/AuthPage.jsx similarity index 100% rename from frontend/src/pages/AuthPage.jsx rename to react/app/src/pages/AuthPage.jsx diff --git a/frontend/src/pages/BasicPage.jsx b/react/app/src/pages/BasicPage.jsx similarity index 100% rename from frontend/src/pages/BasicPage.jsx rename to react/app/src/pages/BasicPage.jsx diff --git a/frontend/src/pages/HomePage.jsx b/react/app/src/pages/HomePage.jsx similarity index 100% rename from frontend/src/pages/HomePage.jsx rename to react/app/src/pages/HomePage.jsx diff --git a/frontend/src/pages/SnippetPage.jsx b/react/app/src/pages/SnippetPage.jsx similarity index 100% rename from frontend/src/pages/SnippetPage.jsx rename to react/app/src/pages/SnippetPage.jsx diff --git a/frontend/src/reportWebVitals.js b/react/app/src/reportWebVitals.js similarity index 100% rename from frontend/src/reportWebVitals.js rename to react/app/src/reportWebVitals.js diff --git a/frontend/src/setupTests.js b/react/app/src/setupTests.js similarity index 100% rename from frontend/src/setupTests.js rename to react/app/src/setupTests.js diff --git a/frontend/src/utils/PrivateRoute.jsx b/react/app/src/utils/PrivateRoute.jsx similarity index 100% rename from frontend/src/utils/PrivateRoute.jsx rename to react/app/src/utils/PrivateRoute.jsx diff --git a/frontend/src/utils/useAxios.jsx b/react/app/src/utils/useAxios.jsx similarity index 100% rename from frontend/src/utils/useAxios.jsx rename to react/app/src/utils/useAxios.jsx diff --git a/static/15761328864140.gif b/static/15761328864140.gif new file mode 100755 index 0000000..1d18923 Binary files /dev/null and b/static/15761328864140.gif differ