Skip to content
Snippets Groups Projects
Commit 4a4a486f authored by Mario Cosma Damiano Di Lorenzo's avatar Mario Cosma Damiano Di Lorenzo
Browse files

Added gomplate to templating and docker compose deploy

parent d2c531bc
No related branches found
No related tags found
No related merge requests found
# otp_config.php
DB_HOST=edugain-db
DB_DATABASE=otp
USER=otp
PASSWORD=xxx
DB_CONFIG_LOCATION=/var/otp_server_config/otp_config.php
......@@ -2,13 +2,17 @@ FROM php:8.1-apache
WORKDIR /var/www/html
RUN docker-php-ext-install mysqli
COPY --from=hairyhenderson/gomplate:v3.11.3 /gomplate /bin/gomplate
COPY --from=docker.io/library/composer:latest /usr/bin/composer /usr/bin/composer
COPY composer.json .
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y git vim
RUN composer update
COPY otp_server.php otp_server.php
COPY config/ config
COPY otp_server_config/ /var/otp_server_config
EXPOSE 80
COPY templating.sh /templating.sh
RUN chmod a+x /templating.sh
......@@ -40,12 +40,13 @@ If you run stuff within secure environment (as you should) you do not need https
When you unpack the code from Git:
- Run composer to pull the TOTP PHP package.
- Create a directory where you will place server config file and copy **otp_config-template.php** there
- Create a directory where you will place server config file and copy **otp_config.php.template** there
using a name of your choice; this file contains access details to the OTP database and it must be read by the server,
but should not be placed within the web-server directory, in case a problem with your PHP could lead to exposure.
- In the config directory, copy `config-template.php` to `config.php` and put in the location of the otp_server config file.
- In the config directory, copy `config.php.template` to `config.php` and put in the location of the otp_server config file.
- Configure your httpd server to be able to execute otp_server.php
### Using Docker
We suggest that you use **--network host** Docker run option which will allow address
......@@ -54,12 +55,12 @@ resolution based on the host machine and standard port 80 for connections.
- You need docker instaled on your host machine
- If you do not want to use ` --network host ` option then decide which port will be mapped to your Docker image (say 8080)
- Download the code from git
- In the ` config ` directory, copy ` config-template.php ` to ` config.php `; do not modify the settings
- In the ` otp_server_config ` directory copy ` otp_config-template.php ` to ` otp_confi.php ` and modify the settings as needed
- In the ` config ` directory, copy ` config.php.template. ` to ` config.php `; do not modify the settings
- In the ` otp_server_config ` directory copy ` otp_config.php.template ` to ` otp_config.php ` and modify the settings as needed
- As root run ` docker build -t otp_server:latest . `
- As root run ` docker run -d --name otp_server --network host --rm otp_server:latest `
### Running the dosker image at boot
### Running the docker image at boot
For systems using systemctl we suggest to install the new service called ` otp-docker `
to do that create the ` otp-docker.service ` file in ` /usr/lib/systemd/system ` with the
contents as below:
......@@ -87,6 +88,23 @@ systemctl start otp-docker
systemctl enable otp-docker
```
## Create and upload the image on the Container Registry
- You need docker installed on your host machine
- Download the code from git
- As root run ` docker login gitlab.software.geant.org:5050 `
- As root run ` docker build -t gitlab.software.geant.org:5050/edugain/ot/totp-server:<VERSION> . `
- As root run ` docker push gitlab.software.geant.org:5050/edugain/ot/totp-server:<VERSION> `
## Using Docker Compose
- You need docker and docker compose installed on your host machine
- Modify the settings file ` .otp.env ` as needed
- Update the ` docker-compose.yml ` file as needed
- As root run ` docker compose up -d `
- As root run ` docker exec otp_server /templating.sh `
## Testing
......
<?php
// location of otp_config.php
//current path corresponds to the settings in the Dockerfile
// therefore you you are using Docker intall do not change this
define('DB_CONFIG_LOCATION', '/var/otp_server_config/otp_config.php');
<?php
// location of otp_config.php
define('DB_CONFIG_LOCATION', '{{ .Env.DB_CONFIG_LOCATION }}');
version: '3.9'
services:
otp_server:
image: "gitlab.software.geant.org:5050/edugain/ot/totp-server:1.0.0"
container_name: "edugain_otp_server"
hostname: "edugain_otp_server"
env_file:
- ".otp.env"
ports:
- "8080:80"
......@@ -7,8 +7,8 @@
* config of the technical site, however the database user must not be the same
* access provileges need to be different
*/
define('DB_HOST','edugain-db');
define('DB_DATABASE','otp');
define('USER', 'otp');
define('PASSWORD', 'xxxx');
define('DB_HOST','{{ .Env.DB_HOST }}');
define('DB_DATABASE','{{ .Env.DB_DATABASE }}');
define('USER', '{{ .Env.USER }}');
define('PASSWORD', '{{ .Env.PASSWORD }}');
#!/bin/bash
gomplate -f /var/www/html/config/config.php.template -o /var/www/html/config/config.php
rm /var/www/html/config/config.php.template
gomplate -f /var/otp_server_config/otp_config.php.template -o /var/otp_server_config/otp_config.php
rm /var/otp_server_config/otp_config.php.template
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment