nao80 commited on
Commit
b155cd5
·
verified ·
1 Parent(s): a6586a0

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +29 -0
entrypoint.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # OCI S3互換エンドポイントの構築
4
+ # 例: https://<namespace>.compat.objectstorage.<region>.oraclecloud.com
5
+ OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
6
+ S3_BUCKET_URL="s3://${S3_BUCKET_NAME}/code-server-workspace/"
7
+ WORKSPACE="$HOME/app/workspace"
8
+
9
+ mkdir -p $WORKSPACE
10
+
11
+ # 1. 起動時にOCIからデータを復元
12
+ echo "Syncing data from OCI Object Storage..."
13
+ aws s3 sync $S3_BUCKET_URL $WORKSPACE --endpoint-url $OCI_ENDPOINT
14
+
15
+ # 2. 定期的にOCIへバックアップするバックグラウンドプロセス
16
+ (
17
+ while true; do
18
+ sleep 300
19
+ echo "Auto-syncing to OCI..."
20
+ aws s3 sync $WORKSPACE $S3_BUCKET_URL --delete --endpoint-url $OCI_ENDPOINT
21
+ done
22
+ ) &
23
+
24
+ # 3. code-serverの起動
25
+ code-server \
26
+ --bind-addr 0.0.0.0:7860 \
27
+ --auth password \
28
+ --disable-telemetry \
29
+ $WORKSPACE