Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
.env
.git
19 changes: 19 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y build-essential
COPY requirements.txt .
RUN pip install --prefix=/install -r requirements.txt

FROM python:3.11-slim
WORKDIR /app
RUN useradd -m appuser
RUN mkdir -p /app/db \
&& chown -R appuser:appuser /app

USER appuser

COPY --from=builder /install /usr/local
COPY . .
USER appuser
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
18 changes: 2 additions & 16 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
"""
URL configuration for config project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/6.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.http import HttpResponse

urlpatterns = [
path('', lambda request: HttpResponse("Backend is running 🚀")),
path('admin/', admin.site.urls),
path('api/', include('core.urls')),
]
2 changes: 2 additions & 0 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.urls import path
from django.http import HttpResponse
from .views import hello_world

urlpatterns = [
path('', lambda request: HttpResponse("API is running 🚀")),
path('hello/', hello_world, name='hello_world'),
]
3 changes: 3 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
django-cors-headers
Django>=4.2
gunicorn
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.9"

services:
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- DEBUG=True

frontend:
build: ./frontend
ports:
- "3000:80"
depends_on:
- backend
21 changes: 21 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build


FROM nginx:alpine

RUN adduser -D appuser \
&& mkdir -p /var/cache/nginx /var/run/nginx /run \
&& chown -R appuser:appuser /var/cache/nginx /var/run/nginx /run

USER appuser



COPY --from=builder /app/dist /usr/share/nginx/html
USER appuser
EXPOSE 80