Set outer ports in .env
This commit is contained in:
@@ -18,7 +18,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error loading .env file: %v", err)
|
log.Fatalf("Error loading .env file: %v", err)
|
||||||
}
|
}
|
||||||
port := os.Getenv("BACKEND_PORT")
|
port := os.Getenv("BACKEND_DOCKER_PORT")
|
||||||
http.HandleFunc("/", handler)
|
http.HandleFunc("/", handler)
|
||||||
fmt.Printf("Serving on port %s\n", port)
|
fmt.Printf("Serving on port %s\n", port)
|
||||||
err = http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
|
err = http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ services:
|
|||||||
latosa-escrima.fr-frontend:
|
latosa-escrima.fr-frontend:
|
||||||
container_name: latosa-frontend
|
container_name: latosa-frontend
|
||||||
image: cems.dev:5000/latosa-escrima.fr:latest
|
image: cems.dev:5000/latosa-escrima.fr:latest
|
||||||
|
env_file: .env
|
||||||
ports:
|
ports:
|
||||||
- 3000:${FRONTEND_PORT}
|
- ${FRONTEND_PORT}:${FRONTEND_DOCKER_PORT}
|
||||||
environment:
|
|
||||||
- NODE_ENV=production
|
|
||||||
- FRONTEND_PORT=${FRONTEND_PORT}
|
|
||||||
restart: always # Ensures the container restarts on failure or Docker restart
|
restart: always # Ensures the container restarts on failure or Docker restart
|
||||||
networks:
|
networks:
|
||||||
- le-network
|
- le-network
|
||||||
@@ -16,22 +14,17 @@ services:
|
|||||||
context: ./backend/
|
context: ./backend/
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
env_file: .env
|
env_file: .env
|
||||||
environment:
|
|
||||||
- PORT="3001"
|
|
||||||
ports:
|
ports:
|
||||||
- "3001:${BACKEND_PORT}"
|
- ${BACKEND_PORT}:${BACKEND_DOCKER_PORT}
|
||||||
networks:
|
networks:
|
||||||
- le-network
|
- le-network
|
||||||
psql:
|
psql:
|
||||||
container_name: latosa-database
|
container_name: latosa-database
|
||||||
image: postgres:17.2-alpine
|
image: postgres:17.2-alpine
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
env_file: .env
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- ${POSTGRES_PORT}:${POSTGRES_DOCKER_PORT}
|
||||||
volumes:
|
volumes:
|
||||||
- le-data:/var/lib/postgresql/data
|
- le-data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -20,8 +20,5 @@ RUN mv .next/standalone/server.js .next/standalone/server.cjs
|
|||||||
|
|
||||||
RUN rm -r ./node_modules
|
RUN rm -r ./node_modules
|
||||||
|
|
||||||
# Expose the default Next.js port
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Start the Next.js app
|
# Start the Next.js app
|
||||||
CMD ["deno", "run", "--allow-env", "--allow-read", "--allow-sys", "--allow-net", ".next/standalone/server.cjs"]
|
CMD ["deno", "run", "--allow-env", "--allow-read", "--allow-sys", "--allow-net", ".next/standalone/server.cjs"]
|
||||||
|
|||||||
2
init.sh
2
init.sh
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
printf "POSTGRES_USER=\nPOSTGRES_PASSWORD=\nPOSTGRES_DB=\n# Docker inner port container\nPOSTGRES_PORT=5432\nBACKEND_PORT=3000\nFRONTEND_PORT=3000\n" > .env
|
printf "POSTGRES_USER=\nPOSTGRES_PASSWORD=\nPOSTGRES_DB=\n#\nDocker\ninner\nport\ncontainer\nPOSTGRES_DOCKER_PORT=5432\nBACKEND_DOCKER_PORT=3000\nFRONTEND_DOCKER_PORT=3000\nPOSTGRES_PORT=5432\nBACKEND_PORT=3001\nFRONTEND_PORT=3000\n" > .env
|
||||||
ln $(pwd)/.env $(pwd)/backend
|
ln $(pwd)/.env $(pwd)/backend
|
||||||
ln $(pwd)/.env $(pwd)/frontend
|
ln $(pwd)/.env $(pwd)/frontend
|
||||||
|
|||||||
19
nginx.conf
Normal file
19
nginx.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
server {
|
||||||
|
server_name TO BE SET;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:FRONTEND_PORT; # Set frontend port based on what you have exposed
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://localhost:BACKEND_PORT; # Set backend port based on what you have exposed
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user