veltrixcode commited on
Commit
ef25800
·
verified ·
1 Parent(s): 27b556f

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +28 -0
start.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # 1. Handle MySQL Persistence
4
+ # If persistent mysql dir doesn't exist, copy the fresh installation there
5
+ if [ ! -d "/data/mysql" ]; then
6
+ echo "Initializing MySQL persistence in /data/mysql..."
7
+ cp -rp /var/lib/mysql /data/mysql
8
+ chown -R mysql:mysql /data/mysql
9
+ fi
10
+
11
+ # Replace the default /var/lib/mysql with a symlink to our persistent data
12
+ rm -rf /var/lib/mysql
13
+ ln -s /data/mysql /var/lib/mysql
14
+ chown -h mysql:mysql /var/lib/mysql
15
+
16
+ # Ensure runtime directory exists
17
+ mkdir -p /var/run/mysqld
18
+ chown mysql:mysql /var/run/mysqld
19
+
20
+ # 2. Start MySQL in the background
21
+ echo "Starting MySQL..."
22
+ /usr/bin/mysqld_safe --skip-syslog &
23
+
24
+ # 3. Start code-server (no password)
25
+ echo "Starting code-server..."
26
+ # We run this as the 'coder' user via the CMD in Dockerfile, or we can switch here.
27
+ # Since this script runs as root (to fix mysql), we drop privileges for code-server.
28
+ exec runuser -u coder -- code-server --bind-addr 0.0.0.0:7860 --auth none /data