Unable to get it working on Caprover
Hi, I am using latest docker images backend fronted, and trying to deploy it on caprover. I got it to the pint where it works the frontend, yet the backend seems to have issues/conflicts with caprover maybe.
this is the template I used:
captainVersion: 4
services:
hi-events-frontend:
image: daveearley/hi.events-frontend
environment:
VITE_FRONTEND_URL: $$cap_frontend_url
VITE_API_URL_CLIENT: $$cap_api_url_client
VITE_API_URL_SERVER: $$cap_api_url_server
VITE_STRIPE_PUBLISHABLE_KEY: $$cap_stripe_publishable_key
caproverExtra:
containerHttpPort: '80'
restart: always
hi-events-backend:
image: daveearley/hi.events-backend
environment:
# Mail Configuration
MAIL_MAILER: $$cap_mail_mailer
MAIL_HOST: $$cap_mail_host
MAIL_PORT: $$cap_mail_port
MAIL_USERNAME: $$cap_mail_username
MAIL_PASSWORD: $$cap_mail_password
MAIL_FROM_ADDRESS: $$cap_mail_from_address
MAIL_FROM_NAME: $$cap_mail_from_name
# Stripe Configuration
STRIPE_PUBLIC_KEY: $$cap_stripe_public_key
STRIPE_SECRET_KEY: $$cap_stripe_secret_key
STRIPE_WEBHOOK_SECRET: $$cap_stripe_webhook_secret
# General Application Configuration
APP_KEY: $$cap_app_key
APP_SAAS_MODE_ENABLED: $$cap_app_saas_mode_enabled
APP_SAAS_STRIPE_APPLICATION_FEE_PERCENT: $$cap_app_saas_stripe_application_fee_percent
APP_FRONTEND_URL: $$cap_app_frontend_url
APP_CDN_URL: $$cap_app_cdn_url
APP_DISABLE_REGISTRATION: $$cap_app_disable_registration
FILESYSTEM_PUBLIC_DISK: $$cap_filesystem_public_disk
FILESYSTEM_PRIVATE_DISK: $$cap_filesystem_private_disk
JWT_SECRET: $$cap_jwt_secret
LOG_CHANNEL: $$cap_log_channel
# AWS Configuration
AWS_ACCESS_KEY_ID: $$cap_aws_access_key_id
AWS_SECRET_ACCESS_KEY: $$cap_aws_secret_access_key
AWS_DEFAULT_REGION: $$cap_aws_default_region
AWS_PUBLIC_BUCKET: $$cap_aws_public_bucket
AWS_PRIVATE_BUCKET: $$cap_aws_private_bucket
# Database Configuration (Hardcoded)
DB_CONNECTION: 'pgsql'
DB_HOST: 'srv-captain--hi-events-db'
DB_PORT: '5432'
DB_DATABASE: 'hi_events_db'
DB_USERNAME: 'hi_events_user'
DB_PASSWORD: 'hi_events_password'
DATABASE_URL: 'postgres://hi_events_user:hi_events_password@srv-captain--hi-events-db:5432/hi_events_db'
# Redis Configuration (Hardcoded)
REDIS_HOST: 'srv-captain--hi-events-redis'
REDIS_USER: 'default'
REDIS_PASSWORD: 'redis_password'
REDIS_PORT: '6379'
REDIS_URL: 'redis://default:redis_password@srv-captain--hi-events-redis:6379'
# Queue Configuration
QUEUE_CONNECTION: $$cap_queue_connection
caproverExtra:
containerHttpPort: '8000'
restart: always
hi-events-db:
image: postgres:13-alpine
environment:
POSTGRES_DB: 'hi_events_db'
POSTGRES_USER: 'hi_events_user'
POSTGRES_PASSWORD: 'hi_events_password'
volumes:
- hi-events-db-data:/var/lib/postgresql/data
caproverExtra:
containerHttpPort: '5432'
notExposeAsWebApp: 'true'
restart: always
hi-events-redis:
image: redis:6-alpine
environment: {}
volumes:
- hi-events-redis-data:/data
caproverExtra:
containerHttpPort: '6379'
notExposeAsWebApp: 'true'
restart: always
volumes:
hi-events-db-data:
hi-events-redis-data:
caproverOneClickApp:
variables:
# Frontend Variables
- id: $$cap_frontend_url
label: VITE_FRONTEND_URL
defaultValue: 'https://your-app.com'
description: 'Frontend URL.'
validRegex: /^https?:\/\/.*$/
- id: $$cap_api_url_client
label: VITE_API_URL_CLIENT
defaultValue: 'https://your-app.com/api'
description: 'API URL for use in the browser.'
validRegex: /^https?:\/\/.*$/
- id: $$cap_api_url_server
label: VITE_API_URL_SERVER
defaultValue: 'https://your-app.com/api'
description: 'API URL for use on the server.'
validRegex: /^https?:\/\/.*$/
- id: $$cap_stripe_publishable_key
label: VITE_STRIPE_PUBLISHABLE_KEY
defaultValue: 'pk_test_51...'
description: 'Stripe publishable key for the frontend.'
validRegex: /^pk_[a-zA-Z0-9_]+$/
# Backend Mail Variables
- id: $$cap_mail_mailer
label: MAIL_MAILER
defaultValue: 'smtp'
description: 'Mail driver to be used.'
validRegex: /^smtp$/
- id: $$cap_mail_host
label: MAIL_HOST
defaultValue: 'smtp.mailtrap.io'
description: 'Mail server host.'
validRegex: /^.*$/
- id: $$cap_mail_port
label: MAIL_PORT
defaultValue: '2525'
description: 'Mail server port.'
validRegex: /^[0-9]+$/
- id: $$cap_mail_username
label: MAIL_USERNAME
defaultValue: 'your-username'
description: 'Mail server username.'
validRegex: /^.*$/
- id: $$cap_mail_password
label: MAIL_PASSWORD
defaultValue: 'your-password'
description: 'Mail server password.'
validRegex: /^.*$/
- id: $$cap_mail_from_address
label: MAIL_FROM_ADDRESS
defaultValue: '[email protected]'
description: 'Mail from address.'
validRegex: /^.*@.*$/
- id: $$cap_mail_from_name
label: MAIL_FROM_NAME
defaultValue: 'Your App Name'
description: 'Mail from name.'
validRegex: /^.*$/
# Backend Stripe Variables
- id: $$cap_stripe_public_key
label: STRIPE_PUBLIC_KEY
defaultValue: 'pk_test_51...'
description: 'Stripe public key.'
validRegex: /^pk_[a-zA-Z0-9_]+$/
- id: $$cap_stripe_secret_key
label: STRIPE_SECRET_KEY
defaultValue: 'sk_test_51...'
description: 'Stripe secret key.'
validRegex: /^sk_[a-zA-Z0-9_]+$/
- id: $$cap_stripe_webhook_secret
label: STRIPE_WEBHOOK_SECRET
defaultValue: 'whsec_...'
description: 'Stripe webhook secret.'
validRegex: /^whsec_[a-zA-Z0-9_]+$/
# General Backend Configuration Variables
- id: $$cap_app_key
label: APP_KEY
defaultValue: 'base64:$$cap_gen_random_hex(64)'
description: 'Application key generated using cap_gen_random_hex. Must be unique.'
validRegex: /^base64:.*$/
- id: $$cap_app_saas_mode_enabled
label: APP_SAAS_MODE_ENABLED
defaultValue: 'true'
description: 'Enable SaaS mode.'
validRegex: /^(true|false)$/
- id: $$cap_app_saas_stripe_application_fee_percent
label: APP_SAAS_STRIPE_APPLICATION_FEE_PERCENT
defaultValue: '1.5'
description: 'Stripe application fee percentage.'
validRegex: /^[0-9]+(\.[0-9]+)?$/
- id: $$cap_app_frontend_url
label: APP_FRONTEND_URL
defaultValue: 'https://your-app.com'
description: 'Frontend URL for backend configuration.'
validRegex: /^https?:\/\/.*$/
- id: $$cap_app_cdn_url
label: APP_CDN_URL
defaultValue: 'https://cdn.your-app.com'
description: 'CDN URL.'
validRegex: /^https?:\/\/.*$/
- id: $$cap_app_disable_registration
label: APP_DISABLE_REGISTRATION
defaultValue: 'false'
description: 'Disable user registration.'
validRegex: /^(true|false)$/
- id: $$cap_filesystem_public_disk
label: FILESYSTEM_PUBLIC_DISK
defaultValue: 's3-public'
description: 'Public filesystem disk.'
validRegex: /^.*$/
- id: $$cap_filesystem_private_disk
label: FILESYSTEM_PRIVATE_DISK
defaultValue: 's3-private'
description: 'Private filesystem disk.'
validRegex: /^.*$/
- id: $$cap_jwt_secret
label: JWT_SECRET
defaultValue: 'base64:$$cap_gen_random_hex(64)'
description: 'JWT secret key generated using cap_gen_random_hex.'
validRegex: /^base64:.*$/
- id: $$cap_log_channel
label: LOG_CHANNEL
defaultValue: 'stderr'
description: 'Log channel.'
validRegex: /^.*$/
# AWS Configuration Variables
- id: $$cap_aws_access_key_id
label: AWS_ACCESS_KEY_ID
defaultValue: 'your-access-key-id'
description: 'AWS access key ID.'
validRegex: /^.*$/
- id: $$cap_aws_secret_access_key
label: AWS_SECRET_ACCESS_KEY
defaultValue: 'your-secret-access-key'
description: 'AWS secret access key.'
validRegex: /^.*$/
- id: $$cap_aws_default_region
label: AWS_DEFAULT_REGION
defaultValue: 'us-west-1'
description: 'AWS region.'
validRegex: /^.*$/
- id: $$cap_aws_public_bucket
label: AWS_PUBLIC_BUCKET
defaultValue: 'your-public-bucket'
description: 'AWS public bucket name.'
validRegex: /^.*$/
- id: $$cap_aws_private_bucket
label: AWS_PRIVATE_BUCKET
defaultValue: 'your-private-bucket'
description: 'AWS private bucket name.'
validRegex: /^.*$/
# Queue Configuration Variable
- id: $$cap_queue_connection
label: QUEUE_CONNECTION
defaultValue: 'redis'
description: 'Queue connection type (redis for production deployments).'
validRegex: /^.*$/
instructions:
start: 'Deploying hi.events with separate frontend and backend services along with PostgreSQL and Redis.'
end: 'Deployment complete. Access your services via the provided URLs.'
displayName: 'hi.events Production'
isOfficial: false
description: 'Deploy hi.events with production-grade services for frontend and backend, integrated with PostgreSQL and Redis.'
documentation: 'https://hi.events/docs/getting-started/deploying'
the frontend can be tested at https://hi-events-frontend.uhl.cloud/ while the backedn should deliver at https://hi-events-backend.uhl.cloud/api it seems to not work. Frontend console logs:
2025-03-20T19:54:22.399460727Z yarn run v1.22.22
2025-03-20T19:54:22.444237976Z $ cross-env NODE_ENV=production node server.js
2025-03-20T19:54:23.129014300Z SSR Serving at http://localhost:5678
2025-03-20T19:54:45.810294780Z No routes matched location "/api/organizers"
2025-03-20T19:54:45.921030085Z No routes matched location "/api/organizers"
2025-03-20T19:57:16.644868461Z No routes matched location "/api/organizers"
2025-03-20T19:57:16.696801099Z No routes matched location "/api/organizers"
2025-03-20T19:57:19.921642181Z No routes matched location "/api/organizers"
2025-03-20T19:57:20.249045022Z No routes matched location "/api/organizers"
2025-03-20T19:58:37.287964741Z No routes matched location "/api/organizers"
2025-03-20T19:58:37.425230336Z No routes matched location "/api/organizers"
backend console logs:
2025-03-20T19:53:29.986149650Z
2025-03-20T19:53:29.986191387Z --------------------------------------------------------------------
2025-03-20T19:53:29.986197865Z ____ ____ _ _ _ _
2025-03-20T19:53:29.986202255Z / ___| ___ _ ____ _____ _ __ / ___|(_) __| | ___ | | | |_ __
2025-03-20T19:53:29.986206478Z \___ \ / _ \ __\ \ / / _ \ __| \___ \| |/ _` |/ _ \ | | | | _ \
2025-03-20T19:53:29.986223504Z ___) | __/ | \ V / __/ | ___) | | (_| | __/ | |_| | |_) |
2025-03-20T19:53:29.986228797Z |____/ \___|_| \_/ \___|_| |____/|_|\__,_|\___| \___/| .__/
2025-03-20T19:53:29.986232376Z |_|
2025-03-20T19:53:29.986235644Z
2025-03-20T19:53:29.986238594Z Brought to you by serversideup.net
2025-03-20T19:53:29.986242011Z --------------------------------------------------------------------
2025-03-20T19:53:30.015664652Z
2025-03-20T19:53:30.015719418Z đ To support Server Side Up projects visit:
2025-03-20T19:53:30.015724261Z https://serversideup.net/sponsor
2025-03-20T19:53:30.015726572Z
2025-03-20T19:53:30.015728717Z -------------------------------------
2025-03-20T19:53:30.015730914Z âšī¸ Container Information
2025-03-20T19:53:30.015733150Z -------------------------------------
2025-03-20T19:53:30.048176415Z
2025-03-20T19:53:30.048211229Z OS: Alpine Linux v3.21
2025-03-20T19:53:30.048217273Z Docker user: root
2025-03-20T19:53:30.048220870Z Docker uid: 0
2025-03-20T19:53:30.048224189Z Docker gid: 0
2025-03-20T19:53:30.048227267Z OPcache: â
Enabled
2025-03-20T19:53:30.048231433Z PHP Version: 8.4.5
2025-03-20T19:53:30.048234558Z Image Version: v3.5.2-13918277297
2025-03-20T19:53:30.048237754Z
2025-03-20T19:53:30.053795711Z (init-webserver-config): Processing /etc/nginx/nginx.conf.template â /etc/nginx/nginx.conf...
2025-03-20T19:53:30.059235424Z (init-webserver-config): Processing /etc/nginx/site-opts.d/http.conf.template â /etc/nginx/site-opts.d/http.conf...
2025-03-20T19:53:30.064794266Z (init-webserver-config): Processing /etc/nginx/site-opts.d/https.conf.template â /etc/nginx/site-opts.d/https.conf...
2025-03-20T19:53:30.066750135Z âšī¸ NOTICE (init-webserver-config): Enabling NGINX site with SSL "off"...
2025-03-20T19:53:30.071814303Z /package/admin/s6-overlay/libexec/preinit: info: /run belongs to uid 82 instead of 0 - fixing it
2025-03-20T19:53:30.141917084Z [20-Mar-2025 19:53:30] NOTICE: fpm is running, pid 90
2025-03-20T19:53:30.143062130Z [20-Mar-2025 19:53:30] NOTICE: ready to handle connections
2025-03-20T19:53:31.157106765Z â
NGINX + PHP-FPM is running correctly.
2025-03-20T19:58:20.528791593Z
2025-03-20T19:58:20.528827744Z --------------------------------------------------------------------
2025-03-20T19:58:20.528834821Z ____ ____ _ _ _ _
2025-03-20T19:58:20.528839876Z / ___| ___ _ ____ _____ _ __ / ___|(_) __| | ___ | | | |_ __
2025-03-20T19:58:20.528843582Z \___ \ / _ \ __\ \ / / _ \ __| \___ \| |/ _` |/ _ \ | | | | _ \
2025-03-20T19:58:20.528847634Z ___) | __/ | \ V / __/ | ___) | | (_| | __/ | |_| | |_) |
2025-03-20T19:58:20.528850971Z |____/ \___|_| \_/ \___|_| |____/|_|\__,_|\___| \___/| .__/
2025-03-20T19:58:20.528853451Z |_|
2025-03-20T19:58:20.528855615Z
2025-03-20T19:58:20.528857717Z Brought to you by serversideup.net
2025-03-20T19:58:20.528859831Z --------------------------------------------------------------------
2025-03-20T19:58:20.555506788Z
2025-03-20T19:58:20.555538608Z đ To support Server Side Up projects visit:
2025-03-20T19:58:20.555542690Z https://serversideup.net/sponsor
2025-03-20T19:58:20.555545046Z
2025-03-20T19:58:20.555547159Z -------------------------------------
2025-03-20T19:58:20.555549318Z âšī¸ Container Information
2025-03-20T19:58:20.555551509Z -------------------------------------
2025-03-20T19:58:20.587971318Z
2025-03-20T19:58:20.587998902Z OS: Alpine Linux v3.21
2025-03-20T19:58:20.588003626Z Docker user: root
2025-03-20T19:58:20.588006046Z Docker uid: 0
2025-03-20T19:58:20.588008226Z Docker gid: 0
2025-03-20T19:58:20.588010327Z OPcache: â
Enabled
2025-03-20T19:58:20.588013565Z PHP Version: 8.4.5
2025-03-20T19:58:20.588015827Z Image Version: v3.5.2-13918277297
2025-03-20T19:58:20.588018005Z
2025-03-20T19:58:20.592313636Z (init-webserver-config): Processing /etc/nginx/nginx.conf.template â /etc/nginx/nginx.conf...
2025-03-20T19:58:20.597176645Z (init-webserver-config): Processing /etc/nginx/site-opts.d/http.conf.template â /etc/nginx/site-opts.d/http.conf...
2025-03-20T19:58:20.601412917Z (init-webserver-config): Processing /etc/nginx/site-opts.d/https.conf.template â /etc/nginx/site-opts.d/https.conf...
2025-03-20T19:58:20.603162059Z âšī¸ NOTICE (init-webserver-config): Enabling NGINX site with SSL "off"...
2025-03-20T19:58:20.607074916Z /package/admin/s6-overlay/libexec/preinit: info: /run belongs to uid 82 instead of 0 - fixing it
2025-03-20T19:58:20.673046851Z [20-Mar-2025 19:58:20] NOTICE: fpm is running, pid 91
2025-03-20T19:58:20.673834670Z [20-Mar-2025 19:58:20] NOTICE: ready to handle connections
2025-03-20T19:58:21.676971493Z â
NGINX + PHP-FPM is running correctly.
Any help is appreciated.
Hi @uhlhosting,
it just so happens, that I have been setting up hi.events inside caprover today. You can paste the hi-events-setup.txt file in the empty OneClick App template and it should just work. Notice: Not all .env variables are exposed.
After that head over to your frontend container and change the nginx configuration for ngnix-frontend.txt (if your backend-service isn't called ticketing-backend you must set the correct name accordingly). This will forward all the requests going to /api to the backend container.
As last step ssh into your server and open the shell inside the backend docker container via docker exec -it <container_id> sh. Then run php artisan migrate to setup the db. That is everything you need to get going.
@DreiDe thanks so much for this, will give it a try asap and provide feedback.
@DreiDe so I deployed it, yet seems the events page it's not working, beside that, all seems to be working fine... https://events-frontend.uhl.cloud/event/1/latino-party-fleda
@uhlhosting Right, good catch. Seems like we have to provide the full API Url in the frontend container to make this work.
VITE_FRONTEND_URL https://events-frontend.uhl.cloud VITE_API_URL_CLIENT https://events-frontend.uhl.cloud/api VITE_API_URL_SERVER https://events-frontend.uhl.cloud/api
@DreiDe so that helped, the only left issue its with S3 connection that also works, and all uploads are done, yet then they do not display on the frontend. So the connection to the buckets works fine, yet the images do not get displayed. getting this from frontend logs:
2025-03-27T21:11:41.941645757Z No routes matched location "/storage/event_cover/pagination-bg-1aBZd.jpg"
2025-03-27T21:13:14.077881497Z No routes matched location "/storage/event_cover/pagination-bg-Yebgy.jpg"
2025-03-27T21:13:14.651281938Z No routes matched location "/storage/event_cover/pagination-bg-Yebgy.jpg"
2025-03-27T21:13:25.614654672Z No routes matched location "/storage/event_cover/pagination-bg-Yebgy.jpg"
Yes, I also noticed this. My fix was to add a rule that forwards all requests to /storage directly to the backend and run artisan storage:link (propably only needed for the local filesystem driver) inside the backend container.
This nginx rule must be added to the frontend-config:
# Forward all calls to /storage directly to backend's /storage
location /storage {
proxy_pass http://srv-captain--ticketing-backend: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 $scheme;
}
@DreiDe do you use local storage or s3 buckets?
I'm using local storage.