veltrixcode commited on
Commit
97e88d7
·
verified ·
1 Parent(s): ef25800

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +16 -21
start.sh CHANGED
@@ -1,28 +1,23 @@
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
 
1
  #!/bin/bash
2
 
3
+ # 1. Setup MySQL Directories (Non-Persistent Mode)
4
+ # Ensure the socket directory exists and is owned by mysql
 
 
 
 
 
 
 
 
 
 
 
 
5
  mkdir -p /var/run/mysqld
6
+ chown -R mysql:mysql /var/run/mysqld
7
 
8
+ # Ensure the data directory permissions are correct
9
+ chown -R mysql:mysql /var/lib/mysql
10
+
11
+ # 2. Start MySQL
12
+ # We use 'runuser' to start it as the 'mysql' user to avoid "running as root" errors
13
+ # We also skip networking checks to ensure it binds locally quickly
14
  echo "Starting MySQL..."
15
+ runuser -u mysql -- /usr/bin/mysqld_safe --skip-grant-tables &
16
+
17
+ # Wait a few seconds for MySQL to initialize
18
+ sleep 5
19
 
20
+ # 3. Start code-server
21
  echo "Starting code-server..."
22
+ # Run as 'coder' user
23
+ exec runuser -u coder -- code-server --bind-addr 0.0.0.0:7860 --auth none /home/coder/projects