npx create-ship-app init
in the terminal then choose desired build type and Digital Ocean Apps as a cloud service provider.
MONGO_URI
variable incorrectly.connect
button.
Connect your application
option. Choose driver and mongo version, and copy connection string. Don’t forget to replace <password>
with your credentials.
Let's start free
to finish database creation.
redis://:<password@<public-endpoint>
. Save this value. It will be needed later when creating the app in Digital Ocean.
Full-Stack
build type requires 2 applications. First for Web and second for API, Migrator, and Scheduler services.
apps/web
for web application and apps/api
for api.APP_ENV
environment variable is typically set based on the environment in which the application is running.
Its value corresponds to the specific environment, such as “development”, “staging” or “production”.
This variable helps the application identify its current environment and load the corresponding configuration.
For the web application, by setting the environment variable APP_ENV
,
the application can determine the environment in which it is running and download the appropriate configuration file:
APP_ENV | File |
---|---|
development | .env.development |
staging | .env.staging |
production | .env.production |
.env
file that houses its environment-specific configuration.
This file typically contains variables like API keys, secrets, or other sensitive information.
To ensure security, it’s crucial to add the .env
file to the .gitignore
file,
preventing it from being tracked and committed to the repository.
So just specify the environment variables that will contain the values of your secrets.
For example, if you have a secret named API_KEY
,
create an environment variable named API_KEY
and set the value of the corresponding secret for it
Variables, added in the Global
section will be available to all resources within the application, while ones added in the ship
section will be available only for that resource. Adding MONGO_CONNECTION
in the global section allows you to use it later if you decide to set up migrator/scheduler resources
dockerfile_path
in the editor.
To deploy your application in a monorepo, it’s essential to modify the source_dir
parameter to the root directory.
This adjustment is necessary to ensure the correct configuration and operation of the applications within the monorepo.
Settings
tab. Select Domains
row to open domain settings and click Add domain
button
You manage your domain
In the bottom section you’ll be asked to copy CNAME alias of your digital ocean application name to record in your dns provider.
Copy that alias and leave the form (do no close it or submit).
DNS
tab and create a new record.Add record
. Select type CNAME
, enter domain name (must be the same you entered in digital ocean settings) and paste alias into target
field.
Make sure Proxy status
toggle enabled..github/workflows
folder, responsible for triggering deployment when you push changes in your repository. If you chose frontend or backend on the initialization step, you’ll have one github workflow for the selected application type.
These actions require a Digital Ocean access token and application ID. Respectively these are DO_ACCESS_TOKEN
and DO_API_STAGING_APP_ID
/DO_WEB_STAGING_APP_ID
/DO_API_PRODUCTION_APP_ID
/DO_WEB_PRODUCTION_APP_ID
.
Navigate to digital ocean and open the API tab on the left sidebar.
Click Generate new token, select a name and set the expiration period.
Also, pick both read and write permissions for the scope.
Create
dropdown menu in the top-right corner, and select the Create Resources From Source Code
option.
Next
.Resource Type
- Job
, Before every deploy
, and change the name of the resource (not required, but might be useful later). Press save and go back to the resources screen.Add Additional Resource from Source
option below the list of added resources, repeat steps 1-2, and navigate to the edit form for a new resource.
Resource Type
- Worker
, save changes and go back.
overview
tab.
(settings tab)
. Change the dockerfile_path
variable to files with migrator and scheduler.
Migrator is placed in the jobs
section. You can also find it by name of the resource. The scheduler is placed in the workers
section.source_dir
parameter to the root directory.
This adjustment is necessary to ensure the correct configuration and operation of the applications within the monorepo.