Skip to content

Commit 0bb09da

Browse files
dcoomberDavid Coomberfmancardi
authored
Testlink 1.9.20 docker manifold (#363)
* Enable proof-of-concept work using Docker * Refinements after testing on Linux * MySQL image must support ARM; first attempt at using maildev for email testing * Working proof-of-concept with maildev * Consistent capitalisation; start up the containers after reset * Removed references to deprecated / deleted PostgreSQL dump * Renamed MySQL DB dump to align with docs * Updated sample DB to TestLink 1.9.20 fixed * Added docker service to restore the sample DB in docs/db_sample * Included the user-defined function in the dump * Set user permissions for the restored DB only; remember the UDF --------- Co-authored-by: David Coomber <10194965-dcoomber@users.noreply.gitlab.com> Co-authored-by: Francisco Mancardi <francisco.mancardi@gmail.com>
1 parent f2ecd28 commit 0bb09da

11 files changed

Lines changed: 2176 additions & 10 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.env
2+
.env.example
3+
docker-compose.yml
4+
Dockerfile

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MYSQL_ROOT_PASSWORD=masterkey

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ config_db.inc.php
55
/custom_config.inc.php
66
**/._*
77
upload_area/**
8+
.env

Dockerfile

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1-
FROM pensiero/apache-php-mysql:latest
1+
FROM php:7.4-apache
22

3-
RUN apt update -q && apt install -yqq --force-yes \
4-
mysql-server
3+
RUN apt update && apt upgrade -y
4+
RUN apt install -y \
5+
default-mysql-client \
6+
zlib1g-dev \
7+
libpng-dev \
8+
libjpeg-dev \
9+
libfreetype-dev
10+
RUN docker-php-ext-install mysqli && \
11+
docker-php-ext-enable mysqli && \
12+
docker-php-ext-configure gd --with-freetype --with-jpeg && \
13+
docker-php-ext-install gd
14+
RUN apt clean
515

6-
# Start mysql
7-
RUN /etc/init.d/mysql 'start'
16+
RUN mkdir -p /var/www/testlink
817

9-
WORKDIR /var/www/public
10-
COPY . ./
18+
WORKDIR /var/www/testlink
19+
20+
COPY . .
21+
COPY ./docker/php.ini-production /usr/local/etc/php/conf.d/php.ini
22+
23+
RUN chown -R www-data:www-data /var/www/testlink
24+
RUN rm -rf docker
25+
ENV APACHE_DOCUMENT_ROOT /var/www/testlink
26+
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
27+
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
28+
29+
USER www-data
30+
31+
EXPOSE 80
32+
CMD ["apache2ctl", "-D", "FOREGROUND"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Next TestLink version will 2.x with a new UX based on the Dashio - Bootstrap Adm
2525
16. [User cries: I WANT HELP !!!](#16-user-cries-i-want-help-)
2626
17. [Use Mantis documentation](#17-use-mantis-documentation)
2727
18. [Link to GITORIOUS COMMITS](#18-link-to-gitorious-commits)
28+
19. [Running Testlink using Docker](./docker/README.md)
2829

2930
## 1. Introduction
3031

docker-compose.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: "3.9"
2+
networks:
3+
testlink:
4+
name: testlink
5+
services:
6+
testlink-mysql:
7+
image: mysql:8.3.0
8+
networks:
9+
- testlink
10+
restart: unless-stopped
11+
user: mysql
12+
command: --default-authentication-plugin=mysql_native_password
13+
environment:
14+
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
15+
volumes:
16+
- mysql:/var/lib/mysql
17+
18+
testlink-maildev:
19+
image: maildev/maildev:latest
20+
networks:
21+
- testlink
22+
ports:
23+
- 1080:1080
24+
- 1025:1025
25+
restart: unless-stopped
26+
environment:
27+
- NODE_TLS_REJECT_UNAUTHORIZED=0
28+
29+
testlink-app: &testlink-app
30+
image: testlink:1.9.20
31+
build: .
32+
restart: unless-stopped
33+
depends_on:
34+
testlink-mysql:
35+
condition: service_started
36+
testlink-maildev:
37+
condition: service_started
38+
networks:
39+
- testlink
40+
ports:
41+
- 8080:80
42+
volumes:
43+
- ./:/var/www/testlink
44+
- ./logs:/var/testlink/logs
45+
- ./upload_area:/var/testlink/upload_area
46+
47+
testlink-restore:
48+
<<: *testlink-app
49+
depends_on:
50+
testlink-app:
51+
condition: service_started
52+
restart: no
53+
ports: []
54+
profiles:
55+
- tools
56+
command: ['/bin/bash', '-c', 'cd ./docs/db_sample && ./restore_sample.sh']
57+
58+
volumes:
59+
mysql:

docker/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Running Testlink using Docker
2+
3+
## Create a dotenv file for Docker
4+
5+
You're going to need a file named `.env` in the project root directory. You can use `.env.example` or create your own.
6+
7+
```bash
8+
cp -n .env.example .env
9+
```
10+
11+
## Build the image
12+
13+
To build a docker image of testlink, you can use the following command:
14+
15+
```bash
16+
docker build --tag testlink:1.9.20 --tag testlink:latest .
17+
```
18+
19+
Alternatively, build without cached layers:
20+
21+
```bash
22+
docker build --no-cache --tag testlink-code:1.9.20 --tag testlink:latest .
23+
```
24+
25+
## Starting up Testlink using `docker compose`
26+
27+
```bash
28+
docker compose up -d
29+
```
30+
31+
You should now be able to open https://localhost:8080 in your browser to proceed with the Testlink setup
32+
33+
### Database configuration
34+
35+
Based on the default `docker-compose.yml` and `.env` configuration, you'll use the following settings for the database setup:
36+
37+
| Key | Value |
38+
| - | - |
39+
| Database type | MySQL/MariaDB (5.6+ / 10.+) |
40+
| Database host | testlink-mysql |
41+
| Database admin login | root |
42+
| Database admin password | masterkey |
43+
44+
You can provide your own values for `Database name`, `TestLink DB login` and `TestLink DB password`.
45+
46+
### Email configuration
47+
48+
Copy the mail configuration to your installation with:
49+
50+
```bash
51+
cp -n docker/custom_config.inc.php ./
52+
```
53+
54+
You can view the test emails at http://localhost:1080
55+
56+
### Restoring the sample database
57+
58+
There is a sample database in `docs/db_sample` which you can restore with:
59+
60+
```bash
61+
docker compose up testlink-restore
62+
```
63+
64+
## Troubleshooting
65+
66+
### Creating the Testlink database user manually
67+
68+
You'll need to create the testlink user yourself should you be presented with the following error during setup:
69+
70+
> 1045 - Access denied for user 'testlink'@'172.29.0.3' (using password: YES)
71+
> TestLink ::: Fatal Error
72+
> Connect to database testlink on Host testlink-mysql fails
73+
> DBMS Error Message: 1045 - Access denied for user 'testlink'@'172.29.0.3' (using password: YES)
74+
75+
Connect to the app or database container and, using the `mysql` CLI, execute the following commands:
76+
77+
```sql
78+
/* update the database name, user name and password
79+
values based on what you specified during setup */
80+
USE `testlink`;
81+
CREATE USER 'testlink'@'%' IDENTIFIED BY 'masterkey';
82+
GRANT SELECT, UPDATE, DELETE, INSERT ON *.* TO 'testlink'@'%' WITH GRANT OPTION;
83+
```
84+
85+
### Resetting your database
86+
87+
If you wish to reset your database, you'll need to delete the mysql volume and `config_db.inc.php`.
88+
89+
```bash
90+
docker compose down
91+
docker volume rm testlink-code_mysql
92+
/bin/rm -f config_db.inc.php
93+
docker compose up -d
94+
```

docker/custom_config.inc.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
// $tlCfg->log_level = 'DEBUG';
4+
5+
# custom configuration file for email
6+
$g_tl_admin_email = 'gandalf@teamst.org';
7+
$g_from_email = 'testlink_system@teamst.org';
8+
$g_return_path_email = 'no_reply@teamst.org';
9+
$g_smtp_host = 'testlink-maildev';
10+
11+
# Urgent = 1, Not Urgent = 5, Disable = 0
12+
$g_mail_priority = 5;
13+
14+
$g_smtp_username = '';
15+
$g_smtp_password = '';
16+
$g_smtp_connection_mode = '';
17+
$g_smtp_port = 1025;
18+
19+
?>

0 commit comments

Comments
 (0)