fix: corrige URLs do frontend para HTTPS e SSL do seeder
- Frontend: adiciona API_URL e BACKOFFICE_URL como variáveis runtime - Seeder: corrige parsing de sslmode do DATABASE_URL - Seeder: aumenta timeout do healthcheck para 30s
This commit is contained in:
parent
cb4ca69a18
commit
11b40fe700
3 changed files with 40 additions and 17 deletions
|
|
@ -39,6 +39,13 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
# Runtime environment variables (read by /api/config endpoint)
|
||||||
|
# These can be overridden at container runtime
|
||||||
|
ARG API_URL=https://api-local.gohorsejobs.com
|
||||||
|
ARG BACKOFFICE_URL=https://b-local.gohorsejobs.com
|
||||||
|
ENV API_URL=$API_URL
|
||||||
|
ENV BACKOFFICE_URL=$BACKOFFICE_URL
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ ENV NODE_ENV=production \
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Health check with longer timeout
|
# Health check with longer timeout for database operations
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 \
|
||||||
CMD wget -qO- http://localhost:8080/health || exit 1
|
CMD wget -qO- http://localhost:8080/health || exit 1
|
||||||
|
|
||||||
CMD ["node", "src/server.js"]
|
CMD ["node", "src/server.js"]
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,27 @@ const {
|
||||||
DB_SSLMODE = 'disable',
|
DB_SSLMODE = 'disable',
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
const config = DATABASE_URL
|
// Parse sslmode from DATABASE_URL if present
|
||||||
|
const parseSslMode = (url) => {
|
||||||
|
const match = url.match(/sslmode=(\w+)/i);
|
||||||
|
return match ? match[1].toLowerCase() : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const sslModeFromUrl = DATABASE_URL ? parseSslMode(DATABASE_URL) : null;
|
||||||
|
const effectiveSslMode = sslModeFromUrl || DB_SSLMODE.toLowerCase();
|
||||||
|
|
||||||
|
// Determine if SSL should be used
|
||||||
|
const shouldUseSsl = effectiveSslMode === 'require' || effectiveSslMode === 'prefer';
|
||||||
|
|
||||||
|
// Clean DATABASE_URL - remove sslmode parameter
|
||||||
|
const cleanDatabaseUrl = DATABASE_URL
|
||||||
|
? DATABASE_URL.replace(/[?&]sslmode=\w+/gi, '').replace(/\?$/, '')
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const config = cleanDatabaseUrl
|
||||||
? {
|
? {
|
||||||
// Remove sslmode from connection string to avoid conflicts
|
connectionString: cleanDatabaseUrl,
|
||||||
connectionString: DATABASE_URL.replace('?sslmode=require', '').replace('&sslmode=require', ''),
|
ssl: shouldUseSsl ? { rejectUnauthorized: false } : false,
|
||||||
ssl: { rejectUnauthorized: false }
|
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
host: DB_HOST,
|
host: DB_HOST,
|
||||||
|
|
@ -27,7 +43,7 @@ const config = DATABASE_URL
|
||||||
user: DB_USER,
|
user: DB_USER,
|
||||||
password: DB_PASSWORD,
|
password: DB_PASSWORD,
|
||||||
database: DB_NAME,
|
database: DB_NAME,
|
||||||
ssl: DB_SSLMODE === 'require' ? { rejectUnauthorized: false } : false,
|
ssl: shouldUseSsl ? { rejectUnauthorized: false } : false,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('🔌 DB Config:', {
|
console.log('🔌 DB Config:', {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue