fix: COPY init.sql into DB image, remove Next.js basePath for Traefik prefix stripping

This commit is contained in:
Monarch055
2026-06-11 09:43:16 +07:00
parent 7e373a28a1
commit 42f06c1128
5 changed files with 20 additions and 13 deletions
+3 -2
View File
@@ -37,7 +37,9 @@ services:
# 3. MySQL Database Service # 3. MySQL Database Service
db: db:
image: mysql:8.0 build:
context: .
dockerfile: ./docker/db/Dockerfile
container_name: gis_db container_name: gis_db
command: --default-authentication-plugin=mysql_native_password command: --default-authentication-plugin=mysql_native_password
# No host port mapping - DB is only accessible internally via gis-network # No host port mapping - DB is only accessible internally via gis-network
@@ -46,7 +48,6 @@ services:
- MYSQL_DATABASE=spbu_db - MYSQL_DATABASE=spbu_db
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql
- ./docker/db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks: networks:
- gis-network - gis-network
+5
View File
@@ -0,0 +1,5 @@
FROM mysql:8.0
# Copy the SQL initialization script into the MySQL entrypoint directory.
# MySQL will automatically run all .sql files here on first startup (when data volume is empty).
COPY docker/db/init.sql /docker-entrypoint-initdb.d/init.sql
+4 -3
View File
@@ -429,10 +429,11 @@
window.location.hostname === '127.0.0.1' || window.location.hostname === '127.0.0.1' ||
window.location.hostname.endsWith('.test') window.location.hostname.endsWith('.test')
) { ) {
nextjsLink.href = 'http://localhost:3000/sistem-km-next'; nextjsLink.href = 'http://localhost:3000';
} else { } else {
// In production/campus server deployment, use the relative subfolder path // In production (Coolify): Traefik routes /sistem-km-next -> next-app container.
nextjsLink.href = './sistem-km-next'; // next-app now serves at root /, so we use the path-based URL on this same host.
nextjsLink.href = window.location.origin + '/sistem-km-next';
} }
}); });
</script> </script>
+3 -3
View File
@@ -1,8 +1,8 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
basePath: '/sistem-km-next', // basePath removed: Coolify's Traefik strips the /sistem-km-next prefix before
/* config options here */ // forwarding to this container, so Next.js must respond at root /.
// The Traefik path /sistem-km-next -> container / mapping handles routing.
}; };
export default nextConfig; export default nextConfig;
+5 -5
View File
@@ -111,7 +111,7 @@ export default function Dashboard() {
const fetchUsers = async () => { const fetchUsers = async () => {
try { try {
const res = await fetch('/sistem-km-next/api/users'); const res = await fetch('/api/users');
if (res.ok) { if (res.ok) {
const data = await res.json(); const data = await res.json();
setUsersList(data.users || []); setUsersList(data.users || []);
@@ -123,7 +123,7 @@ export default function Dashboard() {
e.preventDefault(); e.preventDefault();
setIsSubmittingUser(true); setIsSubmittingUser(true);
try { try {
const res = await fetch('/sistem-km-next/api/users', { const res = await fetch('/api/users', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userFormData) body: JSON.stringify(userFormData)
@@ -149,7 +149,7 @@ export default function Dashboard() {
onConfirm: async () => { onConfirm: async () => {
setConfirmDialog(null); setConfirmDialog(null);
try { try {
const res = await fetch(`/sistem-km-next/api/users?id=${id}`, { method: 'DELETE' }); const res = await fetch(`/api/users?id=${id}`, { method: 'DELETE' });
if (res.ok) { if (res.ok) {
showToastNotification('Pengguna berhasil dihapus!'); showToastNotification('Pengguna berhasil dihapus!');
fetchUsers(); fetchUsers();
@@ -171,7 +171,7 @@ export default function Dashboard() {
onConfirm: async () => { onConfirm: async () => {
setConfirmDialog(null); setConfirmDialog(null);
try { try {
const res = await fetch(`/sistem-km-next/api/hubs?id=${id}`, { method: 'DELETE' }); const res = await fetch(`/api/hubs?id=${id}`, { method: 'DELETE' });
if (res.ok) { if (res.ok) {
showToastNotification('Rumah ibadah dan akun terikat berhasil dihapus!'); showToastNotification('Rumah ibadah dan akun terikat berhasil dihapus!');
fetchData(); fetchData();
@@ -541,7 +541,7 @@ const [isEditMode, setIsEditMode] = useState(false);
setHouseholds(formattedHh); setHouseholds(formattedHh);
} else { } else {
setHouseholds([]); setHouseholds([]);
fetch('/sistem-km-next/api/stats') fetch('/api/stats')
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
if (!isMountedRef.current) return; if (!isMountedRef.current) return;