Skip to content

How to Deploy Dentic with Docker and Docker Compose

  • by

This guide explains how to deploy Dentic using Docker and Docker Compose. This approach packages the frontend, backend, and database into containers for a consistent remote-server deployment.

Prerequisites

Before deploying Dentic, make sure your remote server has:

  • Ubuntu 20.04 or newer
  • Docker 24 or newer
  • Docker Compose v2
  • At least 2 GB RAM
  • SSH access

Step 1 — Install Docker

Install Docker:

curl -fsSL https://get.docker.com | sh

Add your user to the Docker group:

sudo usermod -aG docker $USER

Apply the group change:

newgrp docker

Verify Docker:

docker --version

Step 2 — Download Dentic

Clone the Dentic repository:

git clone https://github.com/your-org/dentic.git

Open the Dentic frontend directory:

cd dentic/FRONTEND

Step 3 — Create the Dentic Frontend Dockerfile

Create a Dockerfile in the Dentic frontend root:

nano Dockerfile

Add:

FROM node:18-alpine AS builder

WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

FROM node:18-alpine

WORKDIR /app

COPY --from=builder /app/build ./build
COPY server.js .
COPY package*.json ./

RUN npm ci --omit=dev

EXPOSE 3001

CMD ["node", "server.js"]

This creates a production Docker image for the Dentic React frontend.

Step 4 — Create the Dentic Backend Dockerfile

Create:

backend/Dockerfile

Add:

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev

COPY . .

EXPOSE 5000

CMD ["node", "server.js"]

This creates a production image for the Dentic backend.

Step 5 — Create Docker Compose Configuration

In the Dentic frontend root, create:

docker-compose.yml

Add:

version: "3.9"

services:
  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: dentic_db
      MYSQL_USER: dentic_user
      MYSQL_PASSWORD: StrongPassword!
    volumes:
      - db_data:/var/lib/mysql

  backend:
    build: ./backend
    restart: always
    depends_on:
      - db
    environment:
      PORT: 5000
      DB_HOST: db
      DB_PORT: 3306
      DB_NAME: dentic_db
      DB_USER: dentic_user
      DB_PASSWORD: StrongPassword!
      JWT_SECRET: your_jwt_secret
      OPENAI_API_KEY: sk-...
    ports:
      - "5000:5000"

  frontend:
    build: .
    restart: always
    depends_on:
      - backend
    ports:
      - "3001:3001"

volumes:
  db_data:

Replace all example passwords and secrets with secure production values.

Step 6 — Upload Dentic to the Server

You can clone the Dentic repository directly on the server or copy the project using scp.

For example:

scp -r ./dentic/FRONTEND your_user@your_server_ip:/home/your_user/dentic

Then navigate to the project:

cd /home/your_user/dentic

Step 7 — Start Dentic Containers

Build and start Dentic:

docker compose up -d --build

Check the containers:

docker compose ps

View Dentic logs:

docker compose logs -f

The Dentic frontend runs on port 3001, while the backend runs on port 5000.

Step 8 — Configure Nginx for Dentic

For a production deployment, use Nginx as a reverse proxy.

Install Nginx on the host:

sudo apt install nginx -y

Configure Nginx to send frontend requests to port 3001 and API requests to port 5000, as shown in the standard Dentic Nginx configuration.

After configuring Nginx, test it:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Step 9 — Enable HTTPS for Dentic

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Create an SSL certificate:

sudo certbot --nginx -d your_domain.com

Your Dentic installation will then be accessible securely over HTTPS.

Step 10 — Update Dentic

Pull the latest Dentic code:

git pull origin main

Stop the current containers:

docker compose down

Rebuild and restart Dentic:

docker compose up -d --build

Step 11 — Production Security for Dentic

For a production Dentic deployment:

  • Never commit .env files or API secrets.
  • Use Docker secrets or a secure secrets-management service.
  • Set NODE_ENV=production.
  • Restrict backend CORS to your Dentic domain.
  • Use a strong JWT secret.
  • Keep MySQL inaccessible from the public internet.
  • Use a managed database such as AWS RDS or another durable database service for higher availability.
  • Configure regular backups for the Dentic database.