mirror of
https://github.com/theoleuthardt/werkzeugkiste.git
synced 2026-06-13 09:37:53 +00:00
fix: configure docker compose and fastify cors with .env file for local and production environment
This commit is contained in:
parent
4943846db7
commit
d75f0c4626
5 changed files with 23 additions and 13 deletions
7
.env
Normal file
7
.env
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
####### LOCAL DEVELOPMENT #######
|
||||||
|
NODE_ENV=development
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
|
FRONTEND_PORT=3000
|
||||||
|
BACKEND_PORT=4000
|
||||||
|
BACKEND=http://localhost:4000
|
||||||
|
CORS_ALLOWED_ORIGIN=http://localhost:3000
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -32,7 +32,8 @@ yarn-error.log*
|
||||||
.pnpm-debug.log*
|
.pnpm-debug.log*
|
||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files (can opt-in for committing if needed)
|
||||||
.env*
|
frontend/.env
|
||||||
|
backend/.env
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { removeBG } from "./src/routes/removebg.route";
|
||||||
const app = Fastify({ logger: true });
|
const app = Fastify({ logger: true });
|
||||||
|
|
||||||
app.register(cors, {
|
app.register(cors, {
|
||||||
origin: "*",
|
origin: process.env.CORS_ALLOWED_ORIGIN || "*",
|
||||||
exposedHeaders: "Content-Disposition",
|
exposedHeaders: "Content-Disposition",
|
||||||
methods: "POST",
|
methods: "POST",
|
||||||
allowedHeaders: "Content-Type",
|
allowedHeaders: "Content-Type",
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,14 @@ services:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: werkzeugkiste-frontend
|
container_name: werkzeugkiste-frontend
|
||||||
|
env_file: .env
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=${NODE_ENV}
|
||||||
- HOSTNAME=0.0.0.0
|
- HOSTNAME=${HOSTNAME}
|
||||||
- PORT=3000
|
- PORT=${FRONTEND_PORT}
|
||||||
- backend_url=http://backend:4000
|
- BACKEND_URL=${BACKEND}
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "${FRONTEND_PORT}:3000"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
|
|
@ -18,13 +19,14 @@ services:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: werkzeugkiste-backend
|
container_name: werkzeugkiste-backend
|
||||||
|
env_file: .env
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=${NODE_ENV}
|
||||||
- HOSTNAME=0.0.0.0
|
- HOSTNAME=${HOSTNAME}
|
||||||
- PORT=4000
|
- PORT=${BACKEND_PORT}
|
||||||
- CORS_ORIGIN=http://frontend:3000
|
- CORS_ALLOWED_ORIGIN=${CORS_ALLOWED_ORIGIN}
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- "${BACKEND_PORT}:4000"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { NextConfig } from "next";
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
env: {
|
env: {
|
||||||
backend_url: "http://localhost:4000",
|
backend_url: process.env.BACKEND_URL || "http://localhost:4000",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue