Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin1999Stark committed Aug 29, 2024
1 parent aacf57e commit 96b4356
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 34 deletions.
1 change: 1 addition & 0 deletions Backend/backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dj-rest-auth = "*"
django-allauth = "*"
requests = "*"
djangorestframework-simplejwt = "*"
gunicorn = "*"

[dev-packages]

Expand Down
18 changes: 17 additions & 1 deletion Backend/backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions Frontend/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
FROM node
# Step 1: Build the application
FROM node:18 AS build

WORKDIR /app

# Kopiere nur package.json und package-lock.json für den npm install-Befehl
COPY package.json .
COPY package-lock.json .

RUN npm install

COPY . .
# Kopiere den Rest des Codes nach dem Installieren der Dependencies
COPY . .

# Baue die Anwendung
RUN npm run build

# Step 2: Serve the application
FROM nginx:alpine


COPY nginx.conf /etc/nginx/nginx.conf

# Kopiere die gebauten Dateien in das Nginx-Verzeichnis
COPY --from=build /app/dist /usr/share/nginx/html

# Nginx auf Port 8080 aussetzen
EXPOSE 8080

# Nginx im Vordergrund ausführen
CMD ["nginx", "-g", "daemon off;"]
39 changes: 39 additions & 0 deletions Frontend/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;

server {
listen 8080;
server_name mac-server;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri /index.html;
}

# Optionale Fehlerseiten
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
internal;
}
}
}
40 changes: 19 additions & 21 deletions Frontend/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function App() {
});

const [loggedIn, setLoggedIn] = useState<boolean>(false);
const [user, setUser] = useState<User | null>(null);
const [, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState<boolean>(true);

const handleResize = () => {
Expand Down Expand Up @@ -108,26 +108,24 @@ function App() {
)}

{/* Protected Routes */}
{loggedIn && (
<Route element={<ProtectedRoute loggedIn={loggedIn} />}>
<Route path="/planer" element={<ReceipePlanerView />} />
<Route path="/meals/create" element={<CreateMeal />} />
<Route path="/meals" element={<MealsOverview />} />
<Route path="/meals/:mealID" element={<MealDetailView />} />
<Route path="/meals/:mealID/edit" element={<EditMeal />} />
<Route path="/meals/:mealID/tags" element={<SetTagsMeal />} />
<Route path="/ingredients/create" element={<CreateIngredient />} />
<Route path="/ingredients" element={<IngredientsOverView />} />
<Route path="/ingredients/:ingredientID" element={<IngredientDetailView />} />
<Route path="/ingredients/:ingredientID/edit" element={<EditIngredient />} />
<Route path="/ingredients/:ingredientID/tags" element={<SetTagsIngredient />} />
<Route path="/lists/" element={<InventoryShoppingList />} />
<Route path="/tags" element={<TagsOverView />} />
<Route path="/tags/create" element={<CreateTag />} />
<Route path="/tags/:tagID/edit" element={<EditTag />} />
<Route path="/profile" element={<Profile />} />
</Route>
)}
<Route element={<ProtectedRoute loggedIn={loggedIn} />}>
<Route path="/planer" element={<ReceipePlanerView />} />
<Route path="/meals/create" element={<CreateMeal />} />
<Route path="/meals" element={<MealsOverview />} />
<Route path="/meals/:mealID" element={<MealDetailView />} />
<Route path="/meals/:mealID/edit" element={<EditMeal />} />
<Route path="/meals/:mealID/tags" element={<SetTagsMeal />} />
<Route path="/ingredients/create" element={<CreateIngredient />} />
<Route path="/ingredients" element={<IngredientsOverView />} />
<Route path="/ingredients/:ingredientID" element={<IngredientDetailView />} />
<Route path="/ingredients/:ingredientID/edit" element={<EditIngredient />} />
<Route path="/ingredients/:ingredientID/tags" element={<SetTagsIngredient />} />
<Route path="/lists/" element={<InventoryShoppingList />} />
<Route path="/tags" element={<TagsOverView />} />
<Route path="/tags/create" element={<CreateTag />} />
<Route path="/tags/:tagID/edit" element={<EditTag />} />
<Route path="/profile" element={<Profile />} />
</Route>

{/* Redirect to login if trying to access protected routes while not logged in */}
<Route path="*" element={<Navigate to={loggedIn ? "/planer" : "/login"} />} />
Expand Down
8 changes: 0 additions & 8 deletions Frontend/frontend/src/Endpoints/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ import axios, { AxiosResponse } from 'axios';
import { User } from '../Datatypes/User';
import { BASE_URL } from './Settings';


const instance = axios.create({
baseURL: BASE_URL,
withCredentials: true,
})


export namespace UserService {


export async function getUserByUserName(name: string, pw: string): Promise<User | null> {

let userData = null;
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
backend:
build:
context: ./Backend/backend
command: python manage.py runserver 0.0.0.0:8000
command: gunicorn backend.wsgi:application --bind 0.0.0.0:8000
volumes:
- .:/code
- ./data/media:/code/media
Expand All @@ -29,7 +29,6 @@ services:
frontend:
build:
context: ./Frontend/frontend
command: npm run dev -- --port 8080
ports:
- "8080:8080"
depends_on:
Expand Down

0 comments on commit 96b4356

Please sign in to comment.