12
12
13
13
Create a ` .env ` file there and add the following environment variables:
14
14
15
- | # | Variable Name | Description | Example |
16
- | --- | ----------------------------- | --------------------------------------------------- | ----------------------------------------------- |
17
- | 1 | DATABASE_URL | The URL to the MongoDB database | localhost:27017/evora |
18
- | 2 | JWT_SECRET | The secret key for JWT | secret-key |
19
- | 3 | JWT_EXPIRES | The expiration time for JWT | 1h |
20
- | 4 | GOOGLE_OAUTH2_CLIENT_ID | The Google client ID | abcxyz |
21
- | 5 | GOOGLE_OAUTH2_CLIENT_SECRET | The Google client secret | secret-key |
22
- | 6 | GOOGLE_OAUTH2_CLIENT_CALLBACK | The Google client callback URL | http://localhost:3000/api/auth/user/callback |
23
- | 7 | ALLOWED_ORIGINS | The allowed origins for CORS (separated by commas ) | http://localhost:3000,https://localhost:3001 |
24
- | 8 | FRONTEND_URL | The URL to the frontend | http://localhost:5173 |
25
-
15
+ | # | Variable Name | Description | Example |
16
+ | --- | ----------------------------- | --------------------------------------------------- | -------------------------------------------- |
17
+ | 1 | DATABASE_URL | The URL to the MongoDB database | localhost:27017/evora |
18
+ | 2 | JWT_SECRET | The secret key for JWT | secret-key |
19
+ | 3 | JWT_EXPIRES | The expiration time for JWT | 1h |
20
+ | 4 | GOOGLE_OAUTH2_CLIENT_ID | The Google client ID | abcxyz |
21
+ | 5 | GOOGLE_OAUTH2_CLIENT_SECRET | The Google client secret | secret-key |
22
+ | 6 | GOOGLE_OAUTH2_CLIENT_CALLBACK | The Google client callback URL | http://localhost:3000/api/auth/user/callback |
23
+ | 7 | ALLOWED_ORIGINS | The allowed origins for CORS (separated by commas ) | http://localhost:3000,https://localhost:3001 |
24
+ | 8 | FRONTEND_URL | The URL to the frontend | http://localhost:5173 |
26
25
27
26
## Development
28
27
@@ -39,3 +38,56 @@ Create a `.env` file there and add the following environment variables:
39
38
```
40
39
41
40
- Step 3: Open the browser and navigate to [ http://localhost:3000 ] ( http://localhost:3000 )
41
+
42
+ ### Build & push container to Docker Hub
43
+
44
+ - Setup ` Dockerfile `
45
+
46
+ ``` bash
47
+ # Example file:
48
+
49
+ FROM node:lts-alpine
50
+ WORKDIR /app
51
+ COPY . .
52
+ RUN yarn install --production
53
+ CMD [" node" , " src/index.js" ]
54
+ EXPOSE 3000
55
+ ```
56
+
57
+ - Build image Docker
58
+
59
+ ``` bash
60
+ docker build -t your-dockerhub-username/image-name:[tag] .
61
+ ```
62
+
63
+ - Push image to Docker Hub
64
+
65
+ ``` bash
66
+ docker push your-dockerhub-username/image-name:[tag]
67
+ ```
68
+
69
+ - Run docker container
70
+
71
+ ``` bash
72
+ docker run -p 3000:3000 --env-file .env your-dockerhub-username/image-name:[tag]
73
+ ```
74
+
75
+ ### Pull & run container
76
+
77
+ - Pull image từ Docker Hub:
78
+
79
+ ``` bash
80
+ docker pull your-dockerhub-username/image-name:[tag]
81
+ ```
82
+
83
+ - Chạy container:
84
+
85
+ ``` bash
86
+ docker run -d -p 3000:3000 --name evora-backend your-dockerhub-username/image-name:[tag]
87
+ ```
88
+
89
+ - Kiểm tra container đang chạy:
90
+
91
+ ``` bash
92
+ docker ps
93
+ ```
0 commit comments