-
Notifications
You must be signed in to change notification settings - Fork 3
chore: fix some small issue for deploy #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4ee26b8
c9f2892
24f2d1d
a225283
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,6 @@ export default defineConfig({ | |
watch: { | ||
usePolling: true, | ||
}, | ||
allowedHosts: true, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||||
version: '3' | ||||||||
|
||||||||
services: | ||||||||
reverse-proxy: | ||||||||
image: traefik:v3.3 | ||||||||
command: | ||||||||
- '--api.insecure=true' | ||||||||
- '--providers.docker=true' | ||||||||
- '--providers.docker.exposedbydefault=false' | ||||||||
- '--providers.file.directory=/etc/traefik/config' | ||||||||
- '--providers.file.watch=true' | ||||||||
- '--entrypoints.web.address=:80' | ||||||||
- '--entrypoints.websecure.address=:443' | ||||||||
ports: | ||||||||
- '80:80' | ||||||||
- '443:443' | ||||||||
- '9001:8080' | ||||||||
volumes: | ||||||||
- /var/run/docker.sock:/var/run/docker.sock | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Docker socket is mounted as a volume. Mounting the Docker socket ( Consider using a more secure approach:
- - /var/run/docker.sock:/var/run/docker.sock
+ # Use a socket proxy with limited permissions instead
+ - socket-proxy:/var/run/docker.sock You would then need to add a socket proxy service to your compose file. 📝 Committable suggestion
Suggested change
|
||||||||
- /etc/letsencrypt:/etc/letsencrypt | ||||||||
- ./traefik-config:/etc/traefik/config | ||||||||
networks: | ||||||||
- traefik_network | ||||||||
extra_hosts: | ||||||||
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Network name inconsistency with code reference. The network defined here ( Ensure network names are consistent across all files: networks:
- traefik_network:
+ codefox_traefik_network:
driver: bridge
|
||||||||
- 'host.docker.internal:host-gateway' | ||||||||
|
||||||||
networks: | ||||||||
traefik_network: | ||||||||
driver: bridge |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
http: | ||
routers: | ||
frontend: | ||
rule: 'Host(`codefox.net`) && !PathPrefix(`/graphql`)' | ||
entrypoints: | ||
- websecure | ||
tls: {} | ||
service: frontend | ||
priority: 10 | ||
|
||
backend: | ||
rule: 'Host(`codefox.net`) && PathPrefix(`/graphql`)' | ||
entrypoints: | ||
- websecure | ||
tls: {} | ||
service: backend | ||
priority: 20 | ||
redirect-all: | ||
rule: 'hostregexp(`{host:.+}`)' | ||
entrypoints: | ||
- web | ||
middlewares: | ||
- redirect-to-https | ||
service: noop | ||
|
||
services: | ||
frontend: | ||
loadBalancer: | ||
servers: | ||
- url: 'http://host.docker.internal:3000' | ||
|
||
backend: | ||
loadBalancer: | ||
servers: | ||
- url: 'http://host.docker.internal:8080' | ||
|
||
noop: | ||
loadBalancer: | ||
servers: | ||
- url: 'http://localhost:9000' | ||
|
||
middlewares: | ||
redirect-to-https: | ||
redirectScheme: | ||
scheme: https | ||
permanent: true | ||
|
||
cors: | ||
headers: | ||
accessControlAllowMethods: | ||
- GET | ||
- POST | ||
- PUT | ||
- DELETE | ||
- OPTIONS | ||
accessControlAllowHeaders: | ||
- Content-Type | ||
- Authorization |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tls: | ||
certificates: | ||
- certFile: /etc/letsencrypt/live/codefox.net/fullchain.pem | ||
keyFile: /etc/letsencrypt/live/codefox.net/privkey.pem |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
NEXT_PUBLIC_GRAPHQL_URL=http://localhost:8080/graphql | ||
|
||
# TLS OPTION for HTTPS | ||
TLS=false | ||
# TRAEFIK OPTION for HTTPS | ||
TRAEFIK_DOMAIN=your_domain.com |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ import puppetter from 'puppeteer'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useMutation } from '@apollo/client/react/hooks/useMutation'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { toast } from 'sonner'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { UPDATE_PROJECT_PHOTO_URL } from '@/graphql/request'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { TLS } from '@/utils/const'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const runningContainers = new Map< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -147,12 +148,25 @@ async function buildAndRunDocker( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log(`Running Docker container: ${containerName}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 3. Run the Docker container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
--network=codefox_traefik_network -p ${exposedPort}:5173 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-v "${directory}:/app" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
${imageName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let runCommand; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (TLS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.entrypoints=websecure" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.tls=true" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
--network=codefox_traefik_network -p ${exposedPort}:5173 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify network name consistency with docker-compose file. The Docker run command references 🏁 Script executed: #!/bin/bash
# Check for network name consistency across the codebase
echo "Network references in Docker files:"
fd -g "docker-compose*.yml" -x grep -E "network|traefik_network" {}
echo "\nNetwork references in code:"
rg -A 1 -B 1 "network=.*traefik" --glob "*.ts" --glob "*.tsx" --glob "*.js" Length of output: 1042 Align Docker network naming for consistency The
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-v "${directory}:/app" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
${imageName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.routers.${subdomain}.entrypoints=web" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
--network=codefox_traefik_network -p ${exposedPort}:5173 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-v "${directory}:/app" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
${imageName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+151
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Refactor to reduce duplication in Docker run commands. The Docker run commands for TLS and non-TLS modes contain significant duplication. This makes maintenance difficult and increases the risk of inconsistencies. Consider refactoring to a more maintainable approach: - let runCommand;
- if (TLS) {
- runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \
- -l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \
- -l "traefik.http.routers.${subdomain}.entrypoints=websecure" \
- -l "traefik.http.routers.${subdomain}.tls=true" \
- -l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \
- --network=codefox_traefik_network -p ${exposedPort}:5173 \
- -v "${directory}:/app" \
- ${imageName}`;
- } else {
- runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \
- -l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \
- -l "traefik.http.routers.${subdomain}.entrypoints=web" \
- -l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \
- --network=codefox_traefik_network -p ${exposedPort}:5173 \
- -v "${directory}:/app" \
- ${imageName}`;
- }
+ // Set entrypoint and TLS options based on TLS setting
+ const entrypoint = TLS ? 'websecure' : 'web';
+ const tlsOption = TLS ? '-l "traefik.http.routers.${subdomain}.tls=true" ' : '';
+
+ const runCommand = `docker run -d --name ${containerName} -l "traefik.enable=true" \
+ -l "traefik.http.routers.${subdomain}.rule=Host(\\"${domain}\\")" \
+ -l "traefik.http.routers.${subdomain}.entrypoints=${entrypoint}" \
+ ${tlsOption}\
+ -l "traefik.http.services.${subdomain}.loadbalancer.server.port=5173" \
+ --network=codefox_traefik_network -p ${exposedPort}:5173 \
+ -v "${directory}:/app" \
+ ${imageName}`; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log(`Executing run command: ${runCommand}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* @description: API URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* @type {string} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* @example 'https://api.example.com' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
export const URL_PROTOCOL_PREFIX = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
process.env.TLS == 'false' ? 'http' : 'https'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* Validate if the current environment is using TLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
export const TLS = process.env.TLS == 'true'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConsider adding a fallback for undefined environment variables. The current implementation doesn't handle cases where the /**
* @description: API URL
* @type {string}
* @example 'https://api.example.com'
*/
export const URL_PROTOCOL_PREFIX =
- process.env.TLS == 'false' ? 'http' : 'https';
+ process.env.TLS === 'false' ? 'http' : 'https';
/**
* Validate if the current environment is using TLS
*/
-export const TLS = process.env.TLS == 'true';
+export const TLS = process.env.TLS === 'true'; I'd also recommend ensuring these variables are properly set in your environments by verifying the configuration files: 🏁 Script executed: #!/bin/bash
# Check if TLS is defined in environment configuration files
# Look for TLS in .env files
echo "Checking .env files for TLS configuration:"
fd -g ".env*" -x cat {} | grep -i "TLS"
# Look for TLS in next.config.js
echo "Checking next.config.js for TLS configuration:"
fd -g "next.config.js" -x cat {} Length of output: 482 Action Required: Implement Fallbacks for Undefined TLS and Update Environment File Search Please make the following changes to ensure consistent behavior across environments:
Please address these points to improve robustness and consistency in TLS handling. 📝 Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security concern: Traefik API is enabled in insecure mode.
Enabling Traefik's API in insecure mode (
--api.insecure=true
) in a production environment exposes the dashboard without authentication, which could be a security risk.Consider either:
📝 Committable suggestion