Ngoc Phuong
Ngoc Phuong
1492 views1 comments

Deploy Tetua with docker

Tetua can be set up manually following the instructions in the getting started section. Docker is another option for installation.

There are things that will be guided in this section:

  • Install Docker
  • Deploy Portainer container
  • Deploy Tetua container
  • Deploy Nginx container

Install Docker

Follow these links for the detailed document on how to install Docker and docker-compose:

Deploy Portainer container

Create portainer docker-compose file:

mkdir -p /opt/containers/portainer/data
touch /opt/containers/docker-compose.yml

Update file /opt/containers/docker-compose.yml with the following content:

version: '3'

services:
  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data:/data

networks:
  proxy:
    external: true

Run the portainer container

cd /opt/containers/portainer
docker-compose up -d

Deploy Tetua container

Download and extract the Tetua binary:

mkdir -p /opt/containers/tetua
cd /opt/containers/tetua
wget https://github.com/ngocphuongnb/tetua/releases/download/v0.0.3-alpha/tetua_0.0.3-alpha_Linux_x86_64.tar.gz
tar -xvf tetua_0.0.3-alpha_Linux_x86_64.tar.gz

Create /opt/containers/Dockerfile with this content;:

FROM ubuntu:bionic

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -yq ca-certificates
RUN apt-get install tzdata -y

WORKDIR /tetua


COPY ./tetua /tetua/tetua

EXPOSE 3000

CMD ./tetua run

Create /opt/containers/docker-compose.yml with this content:

version: '3'

services:
  tetua:
    container_name: tetua
    image: tetua
    restart: always
    build:
      context: .
      dockerfile: ./Dockerfile
    environment:
      APP_ENV: production
    volumes:
      - ./config.json:/tetua/config.json
      - ./public:/tetua/public
      - ./private:/tetua/private
    networks:
      - proxy

networks:
  proxy:
    external: true

Create the Tetua config file:

./tetua init
./tetua setup -u admin -p password

Run the Tetua container

cd /opt/containers/tetua
docker-compose up -d

Deploy Nginx container

mkdir -p /opt/containers/nginx/conf.d

Create file /opt/containers/nginx/docker-compose.yml with this content

version: '3'

services:
  nginx:
    container_name: nginx
    image: nginx
    restart: always
    volumes:
      - ./conf.d/portainer.nginx.conf:/etc/nginx/conf.d/portainer.nginx.conf
      - ./conf.d/tetua.nginx.conf:/etc/nginx/conf.d/tetua.nginx.conf
    ports:
      - 80:80
    command: /bin/sh -c "exec nginx -g 'daemon off;'"
    networks:
      - proxy

networks:
  proxy:
    external: true

Create file /opt/containers/nginx/conf.d/portainer.nginx.conf with this content:

upstream app_portainer {
  server portainer:9000;
}

server {
  listen 80;
  server_name portainer.mytetuaapp.local;
  root /data;

  access_log /var/log/nginx/nginx.portainer.log;
  error_log /var/log/nginx/nginx.portainer.error.log;

  location / {
    index index.html index.htm;
    try_files $uri @portainer;
  }

  location @portainer {
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://app_portainer;
    add_header X-Cache-Status $upstream_cache_status;
  }
}

Create file /opt/containers/nginx/conf.d/tetua.nginx.conf with this content:

upstream app_tetua {
  server tetua:3000;
}

server {
  listen 80;
  server_name mytetuaapp.local;

  access_log /var/log/nginx/nginx.tetua.log;
  error_log /var/log/nginx/nginx.tetua.error.log;

  location / {
    index index.html index.htm;
    try_files $uri @tetua;
  }

  location @tetua {
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://app_tetua;
    add_header X-Cache-Status $upstream_cache_status;
  }
}

Run the Nginx container

cd /opt/containers/nginx
docker-compose up -d

You can now be able to access the Portainer dashboard to manage the server containers: https://portainer.mytetuaapp.local

And the Tetua app will be available at https://mytetuapp.local


Discussion (1)

Klee
Klee  May 21, 2022 03:14 UTC

Hi, can you write a documentation for compiling and deploying tetua without Docker?

LoginRegisterTopics