This commit is contained in:
cdricms
2025-01-14 14:37:50 +01:00
parent 8aadc810d1
commit 8f89f236e7
4 changed files with 28 additions and 1 deletions

View File

@@ -18,7 +18,12 @@ func main() {
if err != nil {
log.Fatalf("Error loading .env file: %v", err)
}
environ := os.Getenv("ENVIRONMENT")
port := os.Getenv("BACKEND_DOCKER_PORT")
if environ == "DEV" {
port = os.Getenv("BACKEND_PORT")
}
http.HandleFunc("/", handler)
fmt.Printf("Serving on port %s\n", port)
err = http.ListenAndServe(fmt.Sprintf(":%s", port), nil)

13
docker-compose.dev.yaml Normal file
View File

@@ -0,0 +1,13 @@
services:
psql:
container_name: latosa-database
image: postgres:17.2-alpine
restart: always
env_file: .env
ports:
- ${POSTGRES_PORT}:${POSTGRES_DOCKER_PORT}
volumes:
- le-data:/var/lib/postgresql/data
volumes:
le-data:

View File

@@ -3,6 +3,15 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
async redirects() {
return [
{
destination: "/api",
source: `http://localhost:${process.env.BACKEND_PORT}`,
permanent: true,
},
];
},
};
export default nextConfig;

View File

@@ -1,4 +1,4 @@
#!/usr/bin/sh
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
printf "ENVIRONMENT=DEV\nPOSTGRES_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)/frontend