Added traefik config
This commit is contained in:
parent
926a6d7bc1
commit
9a21427126
36
docker-compose.server.yml
Normal file
36
docker-compose.server.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: app:latest
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
target: prod
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.calendi.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.calendi.rule=Host(`calendi.strolap.com`)"
|
||||||
|
- "traefik.http.routers.calendi.tls=true"
|
||||||
|
- "traefik.http.routers.calendi.certresolver=strolap"
|
||||||
|
- "traefik.http.services.calendi.loadbalancer.server.port=80"
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:15
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- ./var/postgres_data:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
@ -2,13 +2,19 @@ services:
|
|||||||
app:
|
app:
|
||||||
image: app:latest
|
image: app:latest
|
||||||
build:
|
build:
|
||||||
context: docker
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: docker/Dockerfile
|
||||||
ports:
|
target: dev
|
||||||
- "9010:80"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www/html
|
- ./:/var/www/html
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/sites-enabled/default
|
- ./docker/nginx/default.conf:/etc/nginx/sites-enabled/default
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.app.entrypoints=web"
|
||||||
|
- "traefik.http.routers.app.rule=Host(`calendi.test`)"
|
||||||
|
- "traefik.http.services.app.loadbalancer.server.port=80"
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
@ -20,6 +26,12 @@ services:
|
|||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- ./var/postgres_data:/var/lib/postgresql/data
|
- ./var/postgres_data:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
FROM debian:latest
|
FROM debian:latest AS builder
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
@ -52,8 +52,23 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
|||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Copy entrypoint script
|
# Copy entrypoint script
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
FROM builder AS dev
|
||||||
|
|
||||||
|
# Set entrypoint
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
|
FROM builder AS prod
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
COPY docker/nginx/default.conf /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
|
RUN cd backend && composer install
|
||||||
|
RUN cd frontend && npm install && npm run build
|
||||||
|
|
||||||
# Set entrypoint
|
# Set entrypoint
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@ -1,6 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name calendi.test;
|
||||||
root /var/www/html/backend/public;
|
root /var/www/html/backend/public;
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ server {
|
|||||||
|
|
||||||
# React Frontend
|
# React Frontend
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://localhost:9010/;
|
proxy_pass http://localhost:8888/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "export PORT=9010 && react-scripts start",
|
"start": "export PORT=8888 && react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export type RequestOptions = {
|
|||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:9010';
|
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://calendi.test';
|
||||||
|
|
||||||
export class ApiError extends Error {
|
export class ApiError extends Error {
|
||||||
status: number;
|
status: number;
|
||||||
@ -77,6 +77,7 @@ export async function del<T>(endpoint: string, options?: RequestOptions): Promis
|
|||||||
|
|
||||||
function buildUrl(endpoint: string, params?: Record<string, string | number | boolean>): string {
|
function buildUrl(endpoint: string, params?: Record<string, string | number | boolean>): string {
|
||||||
const url = new URL(`${API_BASE_URL}${endpoint}`);
|
const url = new URL(`${API_BASE_URL}${endpoint}`);
|
||||||
|
url.port = window.location.port;
|
||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
Object.entries(params).forEach(([key, value]) => {
|
Object.entries(params).forEach(([key, value]) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user