@@ -30,11 +30,7 @@ Decide whether you're connecting to a **local PostgreSQL container** (using Dock
30
30
31
31
- Create a ` .env.local ` file based on the template below and specify ` POSTGRES_HOST=postgres ` .
32
32
33
- #### ** For Remote PostgreSQL**
34
-
35
- - Create a ` .env.remote-db ` file and set ` POSTGRES_HOST ` to the external IP or hostname of the remote PostgreSQL instance.
36
-
37
- Example ` .env.local ` :
33
+ ** Example** ` .env.local ` :
38
34
39
35
``` env
40
36
POSTGRES_USER=refactor
@@ -44,41 +40,70 @@ POSTGRES_HOST=postgres
44
40
POSTGRES_PORT=5432
45
41
POSTGRES_SCHEMA=refactor_platform
46
42
DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB
43
+
44
+ BACKEND_LOG_FILTER_LEVEL="DEBUG"
47
45
BACKEND_PORT=4000
48
46
BACKEND_INTERFACE=0.0.0.0
49
47
BACKEND_ALLOWED_ORIGINS="http://localhost:3000,https://localhost:3000"
50
- FRONTEND_PORT=3000
48
+
49
+ BACKEND_SERVICE_PROTOCOL="http"
50
+ BACKEND_SERVICE_PORT=${BACKEND_PORT}
51
+ BACKEND_SERVICE_HOST="localhost"
52
+ BACKEND_API_VERSION="0.0.1"
53
+ FRONTEND_SERVICE_INTERFACE=0.0.0.0
54
+ FRONTEND_SERVICE_PORT=3000
55
+
51
56
USERNAME=appuser
52
57
USER_UID=1000
53
58
USER_GID=1000
54
59
CONTAINER_NAME=refactor-platform
55
60
PLATFORM=linux/arm64
56
61
```
57
62
63
+ #### ** For Remote PostgreSQL**
64
+
65
+ - Create a ` .env.remote-db ` file and set ` POSTGRES_HOST ` to the external IP or hostname of the remote PostgreSQL instance.
66
+
58
67
** Example** ` .env.remote-db ` :
59
68
60
69
``` env
61
- POSTGRES_USER=remote_refactor
62
- POSTGRES_PASSWORD=remote_password
63
- POSTGRES_DB=refactor
64
- POSTGRES_HOST=postgres.example.com
65
- POSTGRES_SCHEMA=refactor_platform
66
- DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB
67
- POSTGRES_PORT=5432
70
+ # PostgreSQL environment variables for local development
71
+ POSTGRES_USER=refactor # Default PostgreSQL user for local development
72
+ POSTGRES_PASSWORD=password # Default PostgreSQL password for local development
73
+ POSTGRES_DB=refactor # Default PostgreSQL database for local development
74
+ POSTGRES_HOST=postgres # The local Docker Compose PostgreSQL container hostname
75
+ POSTGRES_PORT=5432 # PostgreSQL default port for local development
76
+ POSTGRES_SCHEMA=refactor_platform # PostgreSQL schema for the application
77
+ # Database connection URL for the Rust application
78
+ DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
79
+
80
+ # Rust application environment variables
81
+ BACKEND_LOG_FILTER_LEVEL="DEBUG"
82
+ BACKEND_ALLOWED_ORIGINS="http://localhost:3000,https://localhost:3000"
68
83
BACKEND_PORT=4000
69
84
BACKEND_INTERFACE=0.0.0.0
70
- BACKEND_ALLOWED_ORIGINS="http://localhost:3000,https://localhost:3000"
71
- FRONTEND_PORT=3000
72
- USERNAME=remote_appuser
73
- USER_UID=1001
74
- USER_GID=1001
75
- CONTAINER_NAME=refactor-platform
76
- PLATFORM=linux/arm64
85
+
86
+ # Next.js application build & environment variables
87
+ BACKEND_SERVICE_PROTOCOL="http"
88
+ BACKEND_SERVICE_PORT=${BACKEND_PORT}
89
+ BACKEND_SERVICE_HOST="localhost"
90
+ BACKEND_API_VERSION="0.0.1"
91
+ FRONTEND_SERVICE_INTERFACE=0.0.0.0
92
+ FRONTEND_SERVICE_PORT=3000
93
+
94
+ PLATFORM=linux/arm64 # For Raspberry Pi 5 or Apple Silicon
95
+ CONTAINER_NAME="refactor-platform"
96
+
97
+ # App user configuration
98
+ USERNAME=appuser # Username for the non-root user in the container
99
+ USER_UID=1000 # User ID for the appuser
100
+ USER_GID=1000 # Group ID for the appuser
77
101
```
78
102
79
103
### 3. ** Review ` docker-compose.yaml ` **
80
104
81
- The ` docker-compose.yaml ` file uses environment variables defined in your ` .env ` files.
105
+ The ` docker-compose.yaml ` file uses environment variables defined in your ` .env ` file setting important
106
+ configuration variables for both the Rust backend and the Next.js frontend applications.
82
107
83
108
``` yaml
84
109
services :
@@ -132,8 +157,20 @@ services:
132
157
context : https://github.com/refactor-group/refactor-platform-fe.git#main
133
158
dockerfile : Dockerfile
134
159
target : runner
160
+ args :
161
+ NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL : ${BACKEND_SERVICE_PROTOCOL}
162
+ NEXT_PUBLIC_BACKEND_SERVICE_PORT : ${BACKEND_PORT}
163
+ NEXT_PUBLIC_BACKEND_SERVICE_HOST : ${BACKEND_SERVICE_HOST}
164
+ NEXT_PUBLIC_BACKEND_API_VERSION : ${BACKEND_API_VERSION}
165
+ FRONTEND_SERVICE_PORT : ${FRONTEND_SERVICE_PORT}
166
+ FRONTEND_SERVICE_INTERFACE : ${FRONTEND_SERVICE_INTERFACE}
167
+ environment :
168
+ NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL : ${BACKEND_SERVICE_PROTOCOL}
169
+ NEXT_PUBLIC_BACKEND_SERVICE_PORT : ${BACKEND_PORT}
170
+ NEXT_PUBLIC_BACKEND_SERVICE_HOST : ${BACKEND_SERVICE_HOST}
171
+ NEXT_PUBLIC_BACKEND_API_VERSION : ${BACKEND_API_VERSION}
135
172
ports :
136
- - " ${FRONTEND_PORT }:${FRONTEND_PORT }"
173
+ - " ${FRONTEND_SERVICE_PORT }:${FRONTEND_SERVICE_PORT }"
137
174
depends_on :
138
175
- rust-app
139
176
0 commit comments