Skip to content

Commit 800c51f

Browse files
Merge pull request #16 from voltdatalab/caprover-yml
Improve One-Click-App, Begin adding env reload trigger for Next.js app
2 parents f5a8484 + 13acdf4 commit 800c51f

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

Dockerfile.next

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ RUN adduser --system --uid 1001 nextjs
4545
# Required for postgres migrations
4646
# bash is required for migration scripts
4747
# TODO: Consider removing bash from scripts
48-
RUN apk add postgresql-client bash
48+
# Install inotify-tools for file watching
49+
RUN apk add postgresql-client bash inotify-tools
4950
COPY --from=builder /app/public ./public
5051
# Set the correct permission for prerender cache
5152
RUN mkdir .next
@@ -63,10 +64,17 @@ EXPOSE 3000
6364
ENV PORT 3000
6465
# set hostname to localhost
6566
ENV HOSTNAME "0.0.0.0"
66-
# Run scripts then start the server
67+
# Run scripts then start the server with inotify watching .env file
6768
# server.js is created by next build from the standalone output
6869
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
6970
CMD bash -c " \
7071
./tools/database/wait-for-postgres.sh && \
7172
./tools/database/migrate.sh && \
72-
node server.js"
73+
node server.js & \
74+
NODE_PID=\$! && \
75+
while inotifywait -e modify,create,delete,move /app/.env; do \
76+
echo \"Detected change in .env file. Restarting server...\" && \
77+
kill \$NODE_PID && \
78+
node server.js & \
79+
NODE_PID=\$! \
80+
done"

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ services:
114114
networks:
115115
- backend
116116
- frontend
117+
restart: no
117118
depends_on:
118119
ghost:
119120
condition: service_started

xarta.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ services:
2929
XARTA_DB_PASSWORD: $$cap_xarta_db_password
3030
# Variables for Next.js public and server
3131
# TODO: Allow both HTTP and HTTPS
32-
PUBLIC_ROOT_URL: https://$$cap_appname.$$cap_root_domain
32+
PUBLIC_ROOT_URL: $$cap_public_url
3333
caproverExtra:
3434
notExposeAsWebApp: true
3535

3636
$$cap_appname-ghost:
3737
image: ghost:5.118.0
3838
environment:
39-
url: https://$$cap_appname.$$cap_root_domain
39+
url: $$cap_public_url
4040
NODE_ENV: production
4141
# Disable 2FA so that staff logins don't depend on emails
4242
# TODO: Consider reenabling
@@ -88,7 +88,7 @@ services:
8888
CADDY_CONTAINER_NAME: "srv-captain--$$cap_appname"
8989
PROJECT_NAME: srv-captain--$$cap_appname
9090
GHOST_DB_PASSWORD: $$cap_ghost_db_password
91-
PUBLIC_URL: https://$$cap_appname.$$cap_root_domain
91+
PUBLIC_URL: $$cap_public_url
9292
# Force caprover behavior on setup helper
9393
# TODO: Bug in caprover? Entrypoint vanishes when command exists
9494
command: ["/app/setup-entrypoint.sh", "--cap-rover", "--site-title", "$$cap_site_title" , "--name", "$$cap_admin_name", "--email", "$$cap_admin_email", "--password", "$$cap_admin_password" ]
@@ -97,12 +97,27 @@ services:
9797

9898
caproverOneClickApp:
9999
variables:
100-
100+
101+
- id: $$cap_public_url
102+
label: Public URL
103+
description: |
104+
Enter the public URL for your app, which must use HTTPS.
105+
106+
**Important: You must change the default string! ** Either:
107+
108+
- **Use the default app domain:** **replace only the uppercase string `APP_NAME_HERE` with the same value as above**.
109+
110+
- **Use a custom domain:** simply replace the entire value with the domain.
111+
112+
defaultValue: https://APP_NAME_HERE.$$cap_root_domain
113+
validRegex: '/^https:\/\//'
114+
115+
101116
- id: '$$cap_site_title'
102117
label: Site Title
103118
description: Site title. Defaults to Xarta, but you may also use your brand's name, for example.
104119
defaultValue: Xarta
105-
validRegex: '/.{1,}/'
120+
validRegex: '/.{1,}/'
106121

107122
- id: '$$cap_admin_name'
108123
label: Ghost Admin Full name.
@@ -139,7 +154,7 @@ caproverOneClickApp:
139154
description: Password for the Xarta PostgreSQL database.
140155
defaultValue: $$cap_gen_random_hex(16)
141156
validRegex: '/.{8,}/'
142-
157+
143158
instructions:
144159
start: |-
145160
Xarta is a card creation and publishing platform built on top of Ghost CMS.
@@ -164,31 +179,32 @@ caproverOneClickApp:
164179
165180
Open a new browser tab and navigate to the following apps:
166181
167-
https://captain.$$cap_root_domain/#/apps/details/$$cap_appname
182+
[https://captain.$$cap_root_domain/#/apps/details/$$cap_appname](https://captain.$$cap_root_domain/#/apps/details/$$cap_appname)
168183
- In app "$$cap_appname":
184+
- If you're using a custom domain, add it to the list, and then remove the default domain;
169185
- Activate "Enable HTTPS" for the desired url;
170186
- Enable "Force HTTPS by redirecting all HTTP traffic to HTTPS" option;
171187
- Save and restart.
172188
173-
https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-setup-helper
189+
[https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-setup-helper](https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-setup-helper)
174190
- In app "$$cap_appname-setup-helper":
175191
- Go to "Deployment" tab and view the App Logs;
176-
- Copy GHOST_CONTENT_API_KEY and GHOST_ADMIN_API_KEY env variables for $$cap_appname-next container:
177-
- Open a new browser tab: https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-next
178-
- In App Configs, toggle the Bulk Edit button, and add both GHOST_CONTENT_API_KEY and GHOST_ADMIN_API_KEY values;
192+
- Copy `GHOST_CONTENT_API_KEY` and `GHOST_ADMIN_API_KEY` env variables for $$cap_appname-next container:
193+
- Open a new browser tab: [https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-next](https://captain.$$cap_root_domain/#/apps/details/$$cap_appname-setup-helper)
194+
- In App Configs, toggle the Bulk Edit button, and add both `GHOST_CONTENT_API_KEY` and `GHOST_ADMIN_API_KEY` values;
179195
- Save and restart;
180196
- Optional: delete "$$cap_appname-setup-helper" after setup is complete.
181197
182198
- **Important**: Access the Ghost admin panel at:
183-
https://$$cap_appname.$$cap_root_domain/ghost/#/settings/staff
199+
[$$cap_public_url/ghost/#/settings/staff]($$cap_public_url/ghost/#/settings/staff)
184200
- Login with your credentials:
185201
- Email: $$cap_admin_email
186202
- Password: $$cap_admin_password
187203
- **Please change your password as soon as possible!**
188204
- Click your username ($$cap_admin_name) > View Profile > Password > Change
189205
190206
- Finally, access your Xarta instance at:
191-
https://$$cap_appname.$$cap_root_domain/xarta
207+
[$$cap_public_url/xarta]($$cap_public_url/xarta)
192208
193209
-----------------------------------------
194210

0 commit comments

Comments
 (0)