Skip to content

Running AVideo with Docker

Daniel Neto edited this page Feb 24, 2023 · 9 revisions

Docker vs Dedicated Server: Choosing the Right Option for Your Website

Docker is great for small applications or those that don't require a lot of resources, as it allows for quick and easy deployment without dedicated hardware. However, for high-traffic websites that require maximum performance and scalability, a dedicated server with the application installed directly on it is a better option. With a dedicated server, you have full control over the hardware and resources of the server, allowing you to optimize the server configuration to meet the specific requirements of your website. Additionally, a dedicated server offers superior performance, scalability, and customization options compared to a Docker version of AVideo, making it the preferred choice for high-traffic websites.

What is included

This setup will install AVideo and Encoder in a shared Docker container, with their respective databases housed in separate MariaDB containers. The socket will be enabled to improve communication and performance, and crontabs will be installed to ensure scheduled tasks execute at the correct times. Additionally, a separate Docker container will be created to host the live server. This optimized setup improves performance, reliability, and security while balancing practical needs.

Configuration

Environment variables:

As part of the system setup, an env.example file will be provided. This file serves as a template for creating a customized .env file for the system.

To create a .env file with the parameters you listed, follow these steps:

  1. Locate the env.example file in your system setup files.
  2. Open the env.example file in a text editor or IDE.
  3. Copy the entire contents of the env.example file.
  4. Create a new file named ".env" in the same directory as the env.example file.
  5. Paste the copied contents into the new .env file.
  6. Locate the SERVER_NAME variable in the .env file.
  7. Change the value of the SERVER_NAME variable to your domain name. This will be the domain name that you will use to deploy SSL with Let's Encrypt.
  8. Save the .env file.

The SERVER_NAME variable is an important variable to set correctly, as it is used to specify the domain name that will be used for the SSL deployment. This is necessary for properly securing the system with Let's Encrypt and ensuring that the system can be accessed securely over HTTPS.

To replace localhost with your own domain name, simply edit the .env file and replace localhost with your domain name. For example:

SERVER_NAME=example.com

Make sure to use your actual domain name instead of example.com. This will make your website accessible from the internet via your domain name.

By following these steps, you can create a customized .env file that is tailored to your specific environment and needs. This can help to ensure that the system is properly configured and optimized for your use case.

Possible Environment variables:

Each parameter in the .env file corresponds to an environment variable used by the docker-compose file. Here is a brief description of each parameter:

  • SOCKET_PORT: The port number used for the socket server. Defaults to 2053.
  • HTTP_PORT: The port number used for HTTP traffic. Defaults to 80.
  • HTTPS_PORT: The port number used for HTTPS traffic. Defaults to 443.
  • NGINX_RTMP_PORT: The port number used for the RTMP server. Defaults to 1935.
  • NGINX_HTTP_PORT: The port number used for the HTTP server. Defaults to 8080.
  • NGINX_HTTPS_PORT: The port number used for the HTTPS server. Defaults to 8443.
  • DB_MYSQL_HOST: The hostname or IP address of the MySQL database. Defaults to the database.
  • DB_MYSQL_PORT: The port number used by the MySQL database. Defaults to 3306.
  • DB_MYSQL_NAME: The name of the MySQL database. Defaults to avideo.
  • DB_MYSQL_USER: The username used to connect to the MySQL database. Defaults to avideo.
  • DB_MYSQL_PASSWORD: The password used to connect to the MySQL database. Defaults to avideo.
  • SERVER_NAME: The hostname used for the server. Defaults to localhost.
  • CREATE_TLS_CERTIFICATE: Specifies whether to create a TLS certificate or not. Defaults to yes.
  • TLS_CERTIFICATE_FILE: The path to the TLS certificate file. Defaults to /etc/apache2/ssl/localhost.crt.
  • TLS_CERTIFICATE_KEY: The path to the TLS certificate key. Defaults to /etc/apache2/ssl/localhost.key.
  • CONTACT_EMAIL: The email address for the server administrator. Defaults to admin@localhost.
  • SYSTEM_ADMIN_PASSWORD: The password for the system administrator. Defaults to password.
  • WEBSITE_TITLE: The title of the website. Defaults to AVideo.
  • MAIN_LANGUAGE: The main language used for the website. Defaults to en_US.

These parameters are used by the docker-compose file to configure the containers and their associated services. By placing these parameters in a .env file, you can easily modify the environment variables used by the containers without modifying the docker-compose file directly.

Default Ports:

You may want to change the default ports of a project for several reasons, such as:

  1. Avoid conflicts with other applications: If you have other applications running on your machine that are using the same ports as the default ports of your project, you will need to change the default ports to avoid conflicts.
  2. Security reasons: Changing the default ports can also help increase the security of your application by making it harder for attackers to guess which ports are being used by your application. Some attackers may use port scanning techniques to identify open ports on a target machine, and changing the default ports can make it harder for them to identify the ports being used by your application.
  3. Compliance reasons: In some cases, you may need to change the default ports to comply with regulatory requirements or company policies. For example, your organization may have policies that require all web applications to use ports other than the default HTTP and HTTPS ports to reduce the risk of attacks.

Overall, changing the default ports of your project can help avoid conflicts, increase security, and comply with regulatory requirements or company policies.

2053: The port used for the socket server. 80: The port used for HTTP traffic. 443: The port used for HTTPS traffic. 1935: The port used for the RTMP server. 8080: The port used for the HTTP server. 8443: The port used for the HTTPS server.

Run the project

To run this project, you should follow these steps:

  1. Open a terminal window and navigate to the directory where your AVideo directory is located. If you have any existing containers running from a previous run of docker-compose up, it's recommended to stop them first with the command docker-compose down.
  2. Run the docker-compose up command to start the containers defined in the docker-compose.yml file.
  3. Wait for the containers to start and for the services to become available. You should see the output in your terminal showing the status of the various containers and services as they start up.
  4. Once the containers are running, you should be able to access the AVideo application by navigating to the SERVER_NAME you specified in your .env file in your web browser.
  5. Note that running docker-compose up will start the containers in the foreground, so you'll need to keep the terminal window open while the containers are running. If you want to run the containers in the background (i.e., detached mode), you can add the -d flag to the docker-compose up command.

Start the AVideo container in detached mode

docker-compose up -d

This command will start the AVideo container in detached mode, which means it will run in the background. The container will also be automatically restarted if it crashes or the server reboots.

For example, to start the containers in the background, you would run the command docker-compose up -d. To stop the containers running in the background, you can use the docker-compose stop command.

Also, note that when you run docker-compose up, Docker Compose will read the values of the environment variables from your .env file and pass them to the containers as environment variables. So it's important to make sure that your .env file is correctly configured before you run docker-compose up.

Access AVideo

Once the AVideo container is running, you can access it by visiting your domain in a web browser. If everything is set up correctly, you should see the AVideo login page.

Conclusion

In this tutorial, you learned how to run AVideo using Docker. With Docker, you can easily deploy and manage AVideo on your server. If you encounter any issues, refer to the AVideo documentation or seek help from the AVideo community.

TODO

  • Use multiple external encoders
  • User Encoder Network
  • Use multiple live servers
Clone this wiki locally