Self hosted Cotember
Hosting options​
The easest way to run Contember is our Contember Cloud. If you want to host Contember elsewhere, here's a quick tutorial. Contember can be selfhosted almost anywhere.
What you'll need​
- S3-compatible storage (AWS S3, DigitalOcean Spaces, MinIO, CEPH, Zenko CloudServer)
- PostgreSQL database (AWS RDS for PostgreSQL, DigitalOcean Managed Database)
- Some way to run Docker image. You'll need a provider that supports:
Docker,Docker Compose,SSH accessand Proxy server.
It's good idea to run these at one provider but it's not required.
Digital Ocean Droplet​
- Set up DigitalOcean Spaces
- Set up DigitalOcean Managed Database
- Deploy Contember Engine
Deploy Contember Engine​
1. Create droplet​
Use 1-Click Application marketplace from Digital Ocean to create droplet with Docker.
2. Connect to your server with ssh.​
ssh root@your_server_ip
3. Create an empty folder and move into it.​
mkdir contember && cd contember
4. In your empty folder, create .env file.​
nano .env
Add all environment variables to .env file:
LOGIN_TOKEN- Login token used by Contember api (e.g.LOGIN_TOKEN=YOUR_LOGIN_TOKEN)*ROOT_TOKENRoot token used by Contember api (e.g.ROOT_TOKEN=YOUR_ROOT_TOKEN)*ROOT_PASSWORDRoot password for Contember (e.g.ROOT_PASSWORD=password)ROOT_EMAILRoot e-mail for Contember (e.g.ROOT_EMAIL=contember@localhost)S3_KEYKey from your S3 storage (e.g.S3_KEY=yours3key)S3_SECRETSecret from your S3 storage (e.g.S3_SECRET=yours3secret)S3_ENDPOINTEndpoint of your bucket (e.g.S3_ENDPOINT=https://rgn1.yours3provider.com)S3_REGIONRegion if your bucket (e.g.S3_REGION=rgn1)S3_BUCKETYour bucket name (e.g.S3=your-bucket)DB_PASSWORDDatabase password (e.g.DB_PASSWORD=databasePassword)DB_USERDatabase user name (e.g.DB_USER=dbuser)DB_PORTDatabase port (e.g.DB_PORT=5432)DB_HOSTDatabase host (e.g.DB_HOST=your-db-server.com)MAILER_FROMSender e-mail used for Contember notifications, password resets, etc... (e.g.MAILER_FROM=contember@localhost)MAILER_PORTYour SMTP port (e.g.MAILER_PORT=2525)MAILER_HOSTYour SMTP host (e.g.send.your-smtp.com)
*For generating secure tokens you can run openssl rand -hex 20 in your terminal.
5. In same folder, create docker-compose.yaml file.​
nano docker-compose.yaml
version: "2.4"
services:
contember-engine:
image: contember/engine:1.0.0-rc.7
environment:
NODE_ENV: "production"
CONTEMBER_PORT: "4000"
CONTEMBER_ROOT_EMAIL: ${ROOT_EMAIL}
CONTEMBER_ROOT_PASSWORD: ${ROOT_PASSWORD}
CONTEMBER_ROOT_TOKEN: ${ROOT_TOKEN}
CONTEMBER_LOGIN_TOKEN: ${LOGIN_TOKEN}
DEFAULT_DB_HOST: ${DB_HOST}
DEFAULT_DB_PORT: ${DB_PORT}
DEFAULT_DB_USER: ${DB_USER}
DEFAULT_DB_PASSWORD: ${DB_PASSWORD}
DEFAULT_DB_SSL: "true"
DEFAULT_S3_REGION: ${S3_REGION}
DEFAULT_S3_KEY: ${S3_KEY}
DEFAULT_S3_SECRET: ${S3_SECRET}
DEFAULT_S3_ENDPOINT: ${S3_ENDPOINT}
DEFAULT_S3_BUCKET: ${S3_BUCKET}
TENANT_DB_NAME: "tenant"
TENANT_MAILER_HOST: ${MAILER_HOST}
TENANT_MAILER_PORT: ${MAILER_PORT}
TENANT_MAILER_FROM: ${MAILER_FROM}
ports:
- "1481:4000"
6. To run Contember API, use the following command:​
# Execute Docker image detaching the terminal
docker-compose up -d