Skip to content

Commit 42535e1

Browse files
authored
(fix) Documenso: fix build failures (#4382)
- change build command - change port in ENV file; remove unneeded sed cmds - change systemd service file - ensure turbo daemon is stopped to prevent hang on exit
1 parent 990ce16 commit 42535e1

File tree

2 files changed

+68
-64
lines changed

2 files changed

+68
-64
lines changed

ct/documenso.sh

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,51 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /opt/documenso ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
RELEASE=$(curl -fsSL https://api.github.com/repos/documenso/documenso/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32-
msg_info "Stopping ${APP}"
33-
systemctl stop documenso
34-
msg_ok "${APP} Stopped"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/documenso ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
RELEASE=$(curl -fsSL https://api.github.com/repos/documenso/documenso/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
msg_info "Stopping ${APP}"
33+
systemctl stop documenso
34+
msg_ok "${APP} Stopped"
3535

36-
msg_info "Updating ${APP} to ${RELEASE}"
37-
cp /opt/documenso/.env /opt/
38-
rm -rf /opt/documenso
39-
cd /opt
40-
curl -fsSL "https://github.com/documenso/documenso/archive/refs/tags/v${RELEASE}.zip" -o v${RELEASE}.zip
41-
unzip -q v${RELEASE}.zip
42-
mv documenso-${RELEASE} /opt/documenso
43-
cd /opt/documenso
44-
mv /opt/.env /opt/documenso/.env
45-
$STD npm install
46-
$STD npm run build:web
47-
$STD npm run prisma:migrate-deploy
48-
echo "${RELEASE}" >/opt/${APP}_version.txt
49-
msg_ok "Updated ${APP}"
36+
msg_info "Updating ${APP} to ${RELEASE}"
37+
cp /opt/documenso/.env /opt/
38+
rm -rf /opt/documenso
39+
cd /opt
40+
curl -fsSL "https://github.com/documenso/documenso/archive/refs/tags/v${RELEASE}.zip" -o v${RELEASE}.zip
41+
unzip -q v${RELEASE}.zip
42+
mv documenso-${RELEASE} /opt/documenso
43+
cd /opt/documenso
44+
mv /opt/.env /opt/documenso/.env
45+
export TURBO_CACHE=1
46+
export NEXT_TELEMETRY_DISABLED=1
47+
export CYPRESS_INSTALL_BINARY=0
48+
export NODE_OPTIONS="--max-old-space-size=4096"
49+
$STD npm ci
50+
$STD turbo run build --filter=@documenso/remix
51+
$STD npm run prisma:migrate-deploy
52+
$STD turbo daemon stop
53+
echo "${RELEASE}" >/opt/${APP}_version.txt
54+
msg_ok "Updated ${APP}"
5055

51-
msg_info "Starting ${APP}"
52-
systemctl start documenso
53-
msg_ok "Started ${APP}"
56+
msg_info "Starting ${APP}"
57+
systemctl start documenso
58+
msg_ok "Started ${APP}"
5459

55-
msg_info "Cleaning Up"
56-
rm -rf /opt/v${RELEASE}.zip
57-
msg_ok "Cleaned"
58-
msg_ok "Updated Successfully"
59-
else
60-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
61-
fi
62-
exit
60+
msg_info "Cleaning Up"
61+
rm -rf /opt/v${RELEASE}.zip
62+
msg_ok "Cleaned"
63+
msg_ok "Updated Successfully"
64+
else
65+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
66+
fi
67+
exit
6368
}
6469

6570
start

install/documenso-install.sh

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ msg_ok "Setup Functions"
2020

2121
msg_info "Installing Dependencies"
2222
$STD apt-get install -y \
23-
gpg \
24-
libc6 \
25-
make \
26-
cmake \
27-
jq \
28-
postgresql \
29-
python3 \
30-
python3-bcrypt
23+
gpg \
24+
libc6 \
25+
make \
26+
cmake \
27+
jq \
28+
postgresql \
29+
python3 \
30+
python3-bcrypt
3131
msg_ok "Installed Dependencies"
3232

3333
msg_info "Setting up Node.js Repository"
@@ -52,10 +52,10 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8'
5252
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
5353
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'"
5454
{
55-
echo "Documenso-Credentials"
56-
echo "Database Name: $DB_NAME"
57-
echo "Database User: $DB_USER"
58-
echo "Database Password: $DB_PASS"
55+
echo "Documenso-Credentials"
56+
echo "Database Name: $DB_NAME"
57+
echo "Database User: $DB_USER"
58+
echo "Database Password: $DB_PASS"
5959
} >>~/documenso.creds
6060
msg_ok "Set up PostgreSQL"
6161

@@ -68,24 +68,22 @@ mv documenso-${RELEASE} /opt/documenso
6868
cd /opt/documenso
6969
mv .env.example /opt/documenso/.env
7070
sed -i \
71-
-e "s|^NEXTAUTH_SECRET=.*|NEXTAUTH_SECRET='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
72-
-e "s|^NEXT_PRIVATE_ENCRYPTION_KEY=.*|NEXT_PRIVATE_ENCRYPTION_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
73-
-e "s|^NEXT_PRIVATE_ENCRYPTION_SECONDARY_KEY=.*|NEXT_PRIVATE_ENCRYPTION_SECONDARY_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
74-
-e "s|^DOCUMENSO_ENCRYPTION_KEY=.*|DOCUMENSO_ENCRYPTION_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
75-
-e "s|^DOCUMENSO_ENCRYPTION_SECONDARY_KEY=.*|DOCUMENSO_ENCRYPTION_SECONDARY_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
76-
-e "s|^NEXTAUTH_URL=.*|NEXTAUTH_URL=\"http://${LOCAL_IP}:3000\"|" \
77-
-e "s|^NEXT_PUBLIC_WEBAPP_URL=.*|NEXT_PUBLIC_WEBAPP_URL='http://${LOCAL_IP}:9000'|" \
78-
-e "s|^NEXT_PUBLIC_MARKETING_URL=.*|NEXT_PUBLIC_MARKETING_URL=\"http://${LOCAL_IP}:3001\"|" \
79-
-e "s|^NEXT_PRIVATE_INTERNAL_WEBAPP_URL=.*|NEXT_PRIVATE_INTERNAL_WEBAPP_URL=\"http://${LOCAL_IP}:3000\"|" \
80-
-e "s|^NEXT_PRIVATE_DATABASE_URL=.*|NEXT_PRIVATE_DATABASE_URL=\"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME\"|" \
81-
-e "s|^NEXT_PRIVATE_DIRECT_DATABASE_URL=.*|NEXT_PRIVATE_DIRECT_DATABASE_URL=\"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME\"|" \
82-
/opt/documenso/.env
71+
-e "s|^NEXTAUTH_SECRET=.*|NEXTAUTH_SECRET='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
72+
-e "s|^NEXT_PRIVATE_ENCRYPTION_KEY=.*|NEXT_PRIVATE_ENCRYPTION_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
73+
-e "s|^NEXT_PRIVATE_ENCRYPTION_SECONDARY_KEY=.*|NEXT_PRIVATE_ENCRYPTION_SECONDARY_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
74+
-e "s|^DOCUMENSO_ENCRYPTION_KEY=.*|DOCUMENSO_ENCRYPTION_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
75+
-e "s|^DOCUMENSO_ENCRYPTION_SECONDARY_KEY=.*|DOCUMENSO_ENCRYPTION_SECONDARY_KEY='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \
76+
-e "s|^NEXT_PUBLIC_WEBAPP_URL=.*|NEXT_PUBLIC_WEBAPP_URL='http://${LOCAL_IP}:3000'|" \
77+
-e "s|^NEXT_PRIVATE_INTERNAL_WEBAPP_URL=.*|NEXT_PRIVATE_INTERNAL_WEBAPP_URL=\"http://${LOCAL_IP}:3000\"|" \
78+
-e "s|^NEXT_PRIVATE_DATABASE_URL=.*|NEXT_PRIVATE_DATABASE_URL=\"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME\"|" \
79+
-e "s|^NEXT_PRIVATE_DIRECT_DATABASE_URL=.*|NEXT_PRIVATE_DIRECT_DATABASE_URL=\"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME\"|" \
80+
/opt/documenso/.env
8381
export TURBO_CACHE=1
8482
export NEXT_TELEMETRY_DISABLED=1
8583
export CYPRESS_INSTALL_BINARY=0
8684
export NODE_OPTIONS="--max-old-space-size=4096"
8785
$STD npm ci
88-
$STD npm run build:web
86+
$STD turbo run build --filter=@documenso/remix
8987
$STD npm run prisma:migrate-deploy
9088
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
9189
msg_ok "Installed Documenso"
@@ -103,8 +101,8 @@ Description=Documenso Service
103101
After=network.target postgresql.service
104102
105103
[Service]
106-
WorkingDirectory=/opt/documenso/apps/web
107-
ExecStart=/usr/bin/npm start
104+
WorkingDirectory=/opt/documenso
105+
ExecStart=/usr/bin/turbo run start --filter=@documenso/remix
108106
Restart=always
109107
EnvironmentFile=/opt/documenso/.env
110108
@@ -118,6 +116,7 @@ motd_ssh
118116
customize
119117

120118
msg_info "Cleaning up"
119+
$STD turbo daemon stop
121120
$STD apt-get -y autoremove
122121
$STD apt-get -y autoclean
123122
msg_ok "Cleaned"

0 commit comments

Comments
 (0)