Skip to content

Run OpenCal with docker-compose

The fastest way to get OpenCal up and running is with docker-compose. If you want to use Docker, we also recommend checking the system requirements for Docker.

An example setup for running OpenCal with docker-compose can be found here.

1. Pull the example repository

git clone https://git.var-lab.com/opencal/opencal-docker-compose-example.git

2. Create & adjust .env

Some configuration parameters need to be defined in a .env file. For this, the template can be copied with cp .env.dist .env and then adjusted.

An overview of the configuration parameters can be found here.

It is recommended not to publish the ports of the Docker services, but instead to use the loopback interface ( 127.0.0.1) and a proxy to make the ports 80 and 443 (ssl) publicly accessible.

For this, the environment variables BACKEND_PORT and FRONTEND_PORT can be used:

BACKEND_PORT=127.0.0.1:8080
FRONTEND_PORT=127.0.0.1:8090

3. Configure proxy

For example, nginx can be used as a proxy. The configuration may look like this:

server {
    server_name <domain>;
    client_max_body_size 100M;

    location / {
        proxy_pass http://localhost:8090;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;
    }
}

No proxy is used for the backend API, as this task is handled by the frontend.

The nginx proxy can be secured with Let's Encrypt.

4. Start docker compose services

After the .env file has been created and adjusted, the docker-compose services can be started:

docker compose up -d

OpenCal should now be accessible in the browser under the domain configured in the nginx proxy.

5. Create user

Users can be created via Console Command. The command must be executed inside the Docker container.

With the command docker compose ps you get an overview of the running services. The output should look like this:

NAME                                                    IMAGE                                         COMMAND                  SERVICE                CREATED         STATUS                            PORTS
opencal-docker-compose-example-database-1               mysql:8.2                                     "docker-entrypoint.s…"   database               9 seconds ago   Up 8 seconds (healthy)            127.0.0.1:3306->3306/tcp, [::]:3306->3306/tcp
opencal-docker-compose-example-frontend-1               git.var-lab.com:5050/opencal/web-frontend:0   "/docker-entrypoint.…"   frontend               9 seconds ago   Up 3 seconds                      127.0.0.1:80->8080/tcp, [::]:80->8080/tcp
opencal-docker-compose-example-php_backend-1            git.var-lab.com:5050/opencal/backend:0        "docker-entrypoint s…"   php_backend            9 seconds ago   Up 3 seconds (health: starting)   8080/tcp, 9000/tcp
opencal-docker-compose-example-php_backend_consumer-1   git.var-lab.com:5050/opencal/backend:0        "docker-entrypoint p…"   php_backend_consumer   9 seconds ago   Up 3 seconds (health: starting)   8080/tcp, 9000/tcp

The command to create a user must be executed in the backend container opencal-docker-compose-example-php_backend-1. You can access it with

docker compose exec -it opencal-docker-compose-example-php_backend-1 sh

Then execute the following (after adjusting the example data):

[opencal-api]::/srv/app # php bin/console opencal:user:create user@example.com John Doe Secur3Password! 

If the following output appears, everything worked:

[OK] A new user account for "John" has been created.