Skip to content

Commit 199a68e

Browse files
neiescEdinei Cavalcanti
andauthored
some improvements for containers [part 1] (#387)
* add env * Create docker-publish.yml * add .github * add .github * add .github * add .github * add .github * refacory docker * ajutas doc --------- Co-authored-by: Edinei Cavalcanti <[email protected]>
1 parent 2e7978b commit 199a68e

File tree

6 files changed

+178
-31
lines changed

6 files changed

+178
-31
lines changed

.github/workflows/docker-publish.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: [ "*" ]
11+
12+
env:
13+
# Use docker.io for Docker Hub if empty
14+
REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
19+
jobs:
20+
build:
21+
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
# This is used to complete the identity challenge
27+
# with sigstore/fulcio when running outside of PRs.
28+
id-token: write
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
# Install the cosign tool except on PR
35+
# https://github.com/sigstore/cosign-installer
36+
- name: Install cosign
37+
if: github.event_name != 'pull_request'
38+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
39+
with:
40+
cosign-release: 'v2.2.4'
41+
42+
# Set up BuildKit Docker container builder to be able to build
43+
# multi-platform images and export cache
44+
# https://github.com/docker/setup-buildx-action
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
47+
48+
# Login against a Docker registry except on PR
49+
# https://github.com/docker/login-action
50+
- name: Log into registry ${{ env.REGISTRY }}
51+
if: github.event_name != 'pull_request'
52+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
53+
with:
54+
registry: ${{ env.REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
# Extract metadata (tags, labels) for Docker
59+
# https://github.com/docker/metadata-action
60+
- name: Extract Docker metadata
61+
id: meta
62+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
63+
with:
64+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
65+
66+
# Build and push Docker image with Buildx (don't push on PR)
67+
# https://github.com/docker/build-push-action
68+
- name: Build and push Docker image
69+
id: build-and-push
70+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
71+
with:
72+
context: .
73+
push: ${{ github.event_name != 'pull_request' }}
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
cache-from: type=gha
77+
cache-to: type=gha,mode=max
78+
79+
# Sign the resulting Docker image digest except on PRs.
80+
# This will only write to the public Rekor transparency log when the Docker
81+
# repository is public to avoid leaking data. If you would like to publish
82+
# transparency data even for private images, pass --force to cosign below.
83+
# https://github.com/sigstore/cosign
84+
- name: Sign the published Docker image
85+
if: ${{ github.event_name != 'pull_request' }}
86+
env:
87+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
88+
TAGS: ${{ steps.meta.outputs.tags }}
89+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
90+
# This step uses the identity token to provision an ephemeral certificate
91+
# against the sigstore community Fulcio instance.
92+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

Dockerfile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,9 @@ RUN docker-php-ext-install mysqli && \
1313
docker-php-ext-install gd
1414
RUN apt clean
1515

16-
RUN mkdir -p /var/www/testlink
17-
18-
WORKDIR /var/www/testlink
16+
WORKDIR /var/www/html
1917

2018
COPY . .
2119
COPY ./docker/php.ini-production /usr/local/etc/php/conf.d/php.ini
2220

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"]
21+
RUN chown -R www-data:www-data /var/www/html/gui/templates_c

README.containers.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Containers
2+
## compose
3+
```yml
4+
networks:
5+
testlink:
6+
name: testlink
7+
services:
8+
db:
9+
image: mysql:8.3.0
10+
networks:
11+
- testlink
12+
restart: unless-stopped
13+
user: mysql
14+
environment:
15+
- MYSQL_USER=teste
16+
- MYSQL_PASSWORD=teste
17+
- MYSQL_ROOT_PASSWORD=teste
18+
- MYSQL_DATABASE=testlink
19+
volumes:
20+
- mysql:/var/lib/mysql
21+
22+
maildev:
23+
image: maildev/maildev:latest
24+
networks:
25+
- testlink
26+
ports:
27+
- 1080:1080
28+
- 1025:1025
29+
restart: unless-stopped
30+
environment:
31+
- NODE_TLS_REJECT_UNAUTHORIZED=0
32+
33+
app: &app
34+
image: ghcr.io/neiesc/testlink-code:testlink_1_9_20_fixed
35+
restart: unless-stopped
36+
depends_on:
37+
db:
38+
condition: service_started
39+
maildev:
40+
condition: service_started
41+
networks:
42+
- testlink
43+
ports:
44+
- 8090:80
45+
volumes:
46+
- ./logs:/var/testlink/logs:Z
47+
- ./upload_area:/var/testlink/upload_area:Z
48+
49+
restore:
50+
<<: *app
51+
depends_on:
52+
app:
53+
condition: service_started
54+
restart: no
55+
ports: []
56+
profiles:
57+
- tools
58+
command: ['/bin/bash', '-c', 'cd ./docs/db_sample && ./restore_sample.sh']
59+
60+
volumes:
61+
mysql:
62+
```

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ ATTENTION: we have not enough resources to test on all kind of browsers.
179179

180180
## 4. Installation & SECURITY
181181

182+
### With containers
183+
use [README.containers.md](README.containers.md)
184+
185+
### Without containers
186+
182187
The following details the basic steps for installation on any system.
183188
Instructions may seem unix-centric but should work on Windows systems.
184189

README.plugins renamed to README.plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Utilities that will help in writing the plugin class and support files:
6262
available there, then it picks it up from the Global Defaults (Setup through the
6363
`config` method of the plugin) and then default to the "default" parameter provided
6464
in the method definition. See `plugin_config_get` in `plugin_api.php` for details
65-
* plugin_lang_get: Get a string value according to the language configured in
65+
* plugin_lang_get: Get a string value according to the language configured in
6666
TestLink for the current user. See lang directory in TLTest plugin for more info
67-
67+
6868
Writing Templates that will help in Plugin Configuration:
6969
The user might want to create pages that will help in configuring a plugin at a
7070
testproject level or for all projects. These template files will need to reside

docker-compose.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
version: "3.9"
21
networks:
32
testlink:
43
name: testlink
54
services:
6-
testlink-mysql:
5+
db:
76
image: mysql:8.3.0
87
networks:
98
- testlink
109
restart: unless-stopped
1110
user: mysql
12-
command: --default-authentication-plugin=mysql_native_password
1311
environment:
14-
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
12+
- MYSQL_USER=teste
13+
- MYSQL_PASSWORD=teste
14+
- MYSQL_ROOT_PASSWORD=teste
15+
- MYSQL_DATABASE=testlink
1516
volumes:
1617
- mysql:/var/lib/mysql
1718

18-
testlink-maildev:
19+
maildev:
1920
image: maildev/maildev:latest
2021
networks:
2122
- testlink
@@ -26,28 +27,26 @@ services:
2627
environment:
2728
- NODE_TLS_REJECT_UNAUTHORIZED=0
2829

29-
testlink-app: &testlink-app
30-
image: testlink:1.9.20
30+
app: &app
3131
build: .
3232
restart: unless-stopped
3333
depends_on:
34-
testlink-mysql:
34+
db:
3535
condition: service_started
36-
testlink-maildev:
36+
maildev:
3737
condition: service_started
3838
networks:
3939
- testlink
4040
ports:
41-
- 8080:80
41+
- 8090:80
4242
volumes:
43-
- ./:/var/www/testlink
44-
- ./logs:/var/testlink/logs
45-
- ./upload_area:/var/testlink/upload_area
43+
- ./logs:/var/testlink/logs:Z
44+
- ./upload_area:/var/testlink/upload_area:Z
4645

47-
testlink-restore:
48-
<<: *testlink-app
46+
restore:
47+
<<: *app
4948
depends_on:
50-
testlink-app:
49+
app:
5150
condition: service_started
5251
restart: no
5352
ports: []

0 commit comments

Comments
 (0)