add usage of environment variables
This commit is contained in:
@@ -19,7 +19,7 @@ func connectToPostgreSQL() (*gorm.DB, error) {
|
||||
password := os.Getenv("POSTGRES_PASSWORD")
|
||||
dbname := os.Getenv("POSTGRES_DB")
|
||||
host := os.Getenv("POSTGRES_HOST")
|
||||
port := os.Getenv("DB_PORT")
|
||||
port := os.Getenv("POSTGRES_PORT")
|
||||
|
||||
dsn := fmt.Sprintf(
|
||||
"user=%s password=%s dbname=%s host=%s port=%s sslmode=disable",
|
||||
@@ -72,6 +72,6 @@ func main() {
|
||||
c.JSON(200, gin.H{"message": "Hello World"})
|
||||
})
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
port := os.Getenv("BACKEND_PORT")
|
||||
r.Run(fmt.Sprintf(":%s", port))
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ services:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
container_name: backend
|
||||
container_name: "${BACKEND_HOST}"
|
||||
restart: unless-stopped
|
||||
# ports:
|
||||
# - "${BACKEND_PORT}:8080"
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- app-network
|
||||
env_file:
|
||||
- ./.env
|
||||
|
||||
db:
|
||||
image: postgres:16
|
||||
@@ -49,7 +49,5 @@ services:
|
||||
POSTGRES_USER: "${POSTGRES_USER}"
|
||||
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||
POSTGRES_DB: "${POSTGRES_DB}"
|
||||
# ports:
|
||||
# - "${DB_PORT}:5432"
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
@@ -7,10 +7,19 @@ http {
|
||||
charset utf-8;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name _;
|
||||
listen 80;
|
||||
server_name adam-french.co.uk www.adam-french.co.uk;
|
||||
|
||||
# Allow Certbot to access the ACME challenge
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# Redirect everything else to HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
@@ -29,7 +38,7 @@ http {
|
||||
}
|
||||
|
||||
location /posts/ {
|
||||
proxy_pass http://localhost:8080/posts;
|
||||
proxy_pass http://backend:8080/posts;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user