mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
added docker compose for easy setup
This commit is contained in:
1 parent
0ed8fc9ac0
commit
b634b050e5
8 files changed
+115
-6
No files matched your search
@@ -0,0 +1,7 @@
|
||||
# Ignore virtual environment and cache
|
||||
venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
db.sqlite3*
|
||||
.idea/
|
||||
.vscode/
|
||||
@@ -0,0 +1,22 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.14-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the rest of the backend code
|
||||
COPY . .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8000
|
||||
|
||||
# Run the entrypoint script
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
# Apply database migrations
|
||||
echo "Applying database migrations..."
|
||||
python manage.py migrate
|
||||
|
||||
# Create superuser if it doesn't exist
|
||||
echo "Creating superuser..."
|
||||
python manage.py shell <<EOF
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
if not User.objects.filter(username='admin').exists():
|
||||
User.objects.create_superuser('admin', 'admin@example.com', 'password123')
|
||||
print('Superuser created.')
|
||||
else:
|
||||
print('Superuser already exists.')
|
||||
EOF
|
||||
|
||||
# Sync flavors from the API
|
||||
echo "Syncing flavors..."
|
||||
python manage.py sync_flavors
|
||||
|
||||
# Start the server
|
||||
echo "Starting server..."
|
||||
python manage.py runserver 0.0.0.0:8000
|
||||
@@ -0,0 +1,26 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
environment:
|
||||
- PYTHONUNBUFFERED=1
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
ports:
|
||||
- "5173:5173"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- /app/node_modules # Prevents host node_modules from overwriting container
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
volumes:
|
||||
db_data: # Persist the database
|
||||
@@ -0,0 +1,6 @@
|
||||
# Ignore dependencies and build artifacts
|
||||
node_modules/
|
||||
dist/
|
||||
.idea/
|
||||
.vscode/
|
||||
npm-debug.log
|
||||
@@ -0,0 +1,20 @@
|
||||
# Use an official Node runtime as a parent image
|
||||
FROM node:lts-alpine
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of the frontend code
|
||||
COPY . .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 5173
|
||||
|
||||
# Start the development server
|
||||
CMD ["npm", "run", "dev", "--", "--host"]
|
||||
@@ -116,9 +116,8 @@ const App: React.FC = () => {
|
||||
<ThemeProvider theme={theme}>
|
||||
<CssBaseline />
|
||||
<Router>
|
||||
<AppBar position="sticky" elevation={1}>
|
||||
<Container maxWidth={false} sx={{ px: { xs: 2, sm: 4, md: 6 } }}>
|
||||
<Toolbar disableGutters sx={{ minHeight: { xs: 56, sm: 64 } }}>
|
||||
<AppBar position="fixed" elevation={1}>
|
||||
<Toolbar sx={{ minHeight: { xs: 56, sm: 64 }, px: { xs: 2, sm: 4, md: 6 } }}>
|
||||
{isMobile && (
|
||||
<IconButton
|
||||
color="inherit"
|
||||
@@ -160,9 +159,10 @@ const App: React.FC = () => {
|
||||
<MenuItem onClick={() => handleThemeChange('mocha')}>Mocha</MenuItem>
|
||||
</Menu>
|
||||
</Box>
|
||||
</Toolbar>
|
||||
</Container>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
{/* Spacer for the fixed AppBar */}
|
||||
<Toolbar sx={{ minHeight: { xs: 56, sm: 64 } }} />
|
||||
|
||||
<Drawer
|
||||
variant="temporary"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:8000/api/',
|
||||
baseURL: 'http://backend:8000/api/',
|
||||
});
|
||||
|
||||
api.interceptors.request.use((config) => {
|
||||
|
||||
Reference in new issue
Block a user