-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.yaml
More file actions
206 lines (195 loc) · 7.07 KB
/
workflow.yaml
File metadata and controls
206 lines (195 loc) · 7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
permissions:
- '*'
sessions:
session:
useTLS: false
redirect: true
useCustomDomain: false
prompt-for-name:
default: pydio-cells
jobs:
prep:
steps:
- name: Get PW user
run: |
echo "PW_USER=$PW_USER" | tee -a $OUTPUTS
- name: Get service port
ssh:
remoteHost: ${{ inputs.resource.ip }}
run: |
set -x
mkdir -p ${{ inputs.rundir }}
cd ${{ inputs.rundir }}
PW_USER="${{ needs.prep.outputs.PW_USER }}"
echo $PW_USER > PW_USER
availablePort=$(pw agent open-port)
echo availablePort: ${availablePort}
if [ -z "${availablePort}" ]; then
echo "$(date) ERROR: No port found. Exiting job"
exit 1
fi
echo ${availablePort} > SERVICEPORT
# create persistent data directories
mkdir -p mysql_data cells_data
pydio_cells:
ssh:
remoteHost: ${{ inputs.resource.ip }}
needs:
- prep
steps:
- name: Write configs and docker compose
run: |
set -x
cd ${{ inputs.rundir }}
SERVICEPORT=$(cat SERVICEPORT)
PW_USER=$(cat PW_USER)
DATA_DIR="${{ inputs.data_dir }}"
BASE_PATH="/me/session/${PW_USER}/${{ sessions.session }}"
# Write install config for Pydio Cells headless setup
cat > ${{ inputs.rundir }}/install-conf.yml << 'INSTEOF'
frontendlogin: admin
frontendpassword: ${{ inputs.admin_password }}
dbconnectiontype: tcp
dbtcphostname: mysql
dbtcpport: "3306"
dbtcpname: cells
dbtcpuser: pydio
dbtcppassword: cells_db_pw
INSTEOF
# Write nginx config — ACTIVATE proxy strips the session prefix from
# all requests, so everything arrives at / . We use sub_filter to
# rewrite Pydio's HTML/JSON so the browser constructs URLs with the
# session prefix (which ACTIVATE needs to route back to us).
cat > ${{ inputs.rundir }}/nginx.conf << NGINXEOF
worker_processes 1;
events { worker_connections 1024; }
http {
server {
listen 80;
location / {
proxy_pass http://cells:8080;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
# Disable gzip from upstream so sub_filter can rewrite responses
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types text/html application/javascript text/css application/json;
sub_filter '<base href="/"' '<base href="${BASE_PATH}/"';
sub_filter '"BOOTER_URL":"/' '"START_REPOSITORY":"","BOOTER_URL":"${BASE_PATH}/';
sub_filter '"ENDPOINT_REST_API":"/' '"ENDPOINT_REST_API":"${BASE_PATH}/';
sub_filter '"ENDPOINT_S3_GATEWAY":"/' '"ENDPOINT_S3_GATEWAY":"${BASE_PATH}/';
sub_filter '"ENDPOINT_WEBSOCKET":"/' '"ENDPOINT_WEBSOCKET":"${BASE_PATH}/';
sub_filter '"PUBLIC_BASEURI":"/' '"PUBLIC_BASEURI":"${BASE_PATH}/';
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}
}
NGINXEOF
# Write docker-compose.yml
cat > ${{ inputs.rundir }}/docker-compose.yml << YAML
services:
mysql:
image: mysql:8
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ROOT_PASSWORD: cells_root_pw
MYSQL_DATABASE: cells
MYSQL_USER: pydio
MYSQL_PASSWORD: cells_db_pw
volumes:
- ./mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 30
cells:
image: pydio/cells:latest
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
environment:
CELLS_INSTALL_YAML: /pydio/config/install.yml
CELLS_NO_TLS: "1"
CELLS_SITE_BIND: "0.0.0.0:8080"
CELLS_SITE_EXTERNAL: "http://localhost:8080"
CELLS_MINIO_ALLOW_CROSSMOUNT: "true"
volumes:
- ./cells_data:/var/cells
- ./install-conf.yml:/pydio/config/install.yml:ro
- ${DATA_DIR}:/var/cells/data/user_files
nginx:
image: nginx:alpine
depends_on:
- cells
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "${SERVICEPORT}:80"
YAML
- name: Run Pydio Cells
run: |
set -x
cd ${{ inputs.rundir }}
docker compose down
docker compose up
create_session:
ssh:
remoteHost: ${{ inputs.resource.ip }}
needs:
- prep
steps:
- name: Get Hostname & Port
early-cancel: any-job-failed
run: |
set -x
cd ${{ inputs.rundir }}
echo "target_hostname=$(hostname)" | tee -a $OUTPUTS
echo "SESSION_PORT=$(cat SERVICEPORT)" | tee -a $OUTPUTS
- name: Wait for Server To Start
early-cancel: any-job-failed
env:
remote_host: ${{ needs.create_session.outputs.target_hostname }}
remote_port: ${{ needs.create_session.outputs.SESSION_PORT }}
retry:
interval: 5s
max-retries: 120
timeout: 10s
run: curl --fail --silent "http://${remote_host}:${remote_port}/" >/dev/null 2>&1
- name: Update Session
uses: parallelworks/update-session
with:
remotePort: ${{ needs.create_session.outputs.SESSION_PORT }}
target: ${{ inputs.resource.id }}
name: ${{ sessions.session }}
remoteHost: ${{ needs.create_session.outputs.target_hostname }}
'on':
execute:
inputs:
resource:
type: compute-clusters
label: Service Host
autoselect: true
include-workspace: false
tooltip: Resource to host the service
rundir:
label: Run Directory
default: ~/pydio-cells
type: string
admin_password:
label: Admin Password
default: changeme
type: password
tooltip: Password for the Pydio Cells admin account
data_dir:
label: Data Directory
default: $HOME
type: string
tooltip: Directory to expose as files in Pydio Cells