-
Notifications
You must be signed in to change notification settings - Fork 69
Deploying Apps to Our CapRover Server
We maintain a Digital Ocean server to deploy different services app and our database on. Everything that we don't on Vercel. The various apps on this server were either managed or proxied by myProxy. myProxy wasn't an ideal experience and so we decided to replace it with CapRover. CapRover manages deployment and containerization for apps while providing a better development experience and features like automatic ssl management.
Relevant URL and credentials for the CapRover dashboard and admin controls are available with engineering channel
Deploying new apps on the server can be performed in the following ways:
- Dockerize App
- Create an App on CapRover
- Create a GitHub workflow
Create a Dockerfile for your app. https://github.com/garageScript/c0d3-js5/blob/prod/Dockerfile is a sample file you can for node apps using yarn. Optionally add a .dockerignore file to prevent unnecessary files from being included in the image, like https://github.com/garageScript/c0d3-js5/blob/prod/.dockerignore
- Name and create your app
- Open the app's details
- Enable https and websocket support as required.
- If your app needs some environment variables, add them in the App Configs tab
- In your app's GitHub repo, Setup a new workflow.
- You can use this as a template workflow and add things as required https://github.com/jasirzaeem/caprover-deploy#example-workflow
name: 'Deploy to Caprover'
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
caprover-deploy:
runs-on: ubuntu-latest
steps:
# Checking out to the correct repo is required
- name: Checkout Repository
uses: actions/checkout@v2
- name: Deploy to Caprover
uses: JasirZaeem/caprover-deploy@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
server: ${{secrets.CAPROVER_URL}}
password: ${{secrets.CAPROVER_PASSWORD}}
app: "example-app"
GITHUB_TOKEN
is an Environment Variable built into GitHub actions, CAPROVER_URL
is already set in the garageScript organisation, if working on a repo on your personal profile you will have to add it, same for CAPROVER_PASSWORD
- Create a pull request with your new workflow, merge it or do it after approval if required, the setups before this must've all been done before you merge it
`
You are good to go! Your app will now be deployed on [your-app-name].c0d3.com . This is a one time task, All further commits will automatically be built and deployed from here on.
CapRover maintains a collection of OneClick apps, if the app you want to deploy is an existing app you can use this method to deploy it. https://caprover.com/docs/one-click-apps.html
Name and select the app you want and input the required configurations.
You can use this method for apps already running on the server or ones you wish to deploy outside caprover.
- Deploy your app as you would on the server and make note of it's localhost PORT.
- Once done create a new OneClick app using the Nginx Reverse Proxy image
- Enter the app name and the upstream address of your app. For apps running on the server the upstream address is of the form
https://172.17.0.1:PORT
wherePORT
should be replaced with your id you applications port.