Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:improve-template into ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:edge

Proposed by Sergio Durigan Junior
Status: Merged
Merged at revision: 32bd794bc7118254cc93b886d982358237edf63b
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:improve-template
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:edge
Diff against target: 440 lines (+226/-101)
9 files modified
.gitignore (+4/-0)
HACKING.md (+28/-0)
Makefile (+31/-0)
README.md (+47/-99)
data/apache2.yaml (+43/-0)
examples/apache2-deployment.yml (+2/-1)
examples/docker-compose.yml (+2/-1)
templates/apache2-deployment.yml (+56/-0)
templates/docker-compose.yml (+13/-0)
Reviewer Review Type Date Requested Status
Lucas Kanashiro Approve
Canonical Server Pending
Review via email: mp+394370@code.launchpad.net

Description of the change

Start improving the template mechanism. This is a WIP.

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

This is now ready for review. The commit message explains it all.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

FWIW, this will be affected by Valentin's MP 394365.

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Thank you for those changes Sergio!

I was thinking if it would not be better if we do not commit the templates directory and add it to the .gitignore. Otherwise we will need to keep adding commits just updating templates. What do you think? Then we would have the expected content in all git repos but all the template files will be committed only in the templates git repo.

Besides that it LGTM. However, as you mentioned, let's first merge Valentin's MP and adapt this one to match his changes.

review: Needs Fixing
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the review, Lucas. I've updated everything according to Valentin's MP, and also tweaked the Makefile a bit more. I'd appreciate if you could take a second look. Thanks!

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

LGTM, +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
0new file mode 1006440new file mode 100644
index 0000000..2a4e9c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
1templates/README.md
2templates/channels_message.md
3templates/common_usage.md
4templates/header.md
diff --git a/HACKING.md b/HACKING.md
index d929d68..cfa9b96 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -21,3 +21,31 @@ $ docker build -t ubuntu/apache2:test .
21 you can also check the README.md file.21 you can also check the README.md file.
2222
23* If everything goes well submit a merge proposal.23* If everything goes well submit a merge proposal.
24
25# Generating the documentation
26
27The documentation (`README.md` and some files in the `examples/`
28directory) are generated using templates. In order to do that, you
29need to follow some steps.
30
31```
32$ pwd
33~/work/apache2
34$ cd ..
35$ git clone https://github.com/misterw97/RenderDown
36$ cd apache2
37$ make all-doc
38```
39
40If you already have the `RenderDown` repository cloned somewhere else,
41you can tell `make` about it:
42
43```
44$ RENDERDOWN=/path/to/renderdown.py make all-doc
45```
46
47# Hacking the documentation templates
48
49You can find some of the templates used to generated the documentation
50inside the `templates/` directory. You can also look at the `data/`
51directory for the files used to feed the templates.
diff --git a/Makefile b/Makefile
24new file mode 10064452new file mode 100644
index 0000000..6a49a17
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,31 @@
1RENDERDOWN ?= ../RenderDown/renderdown.py
2PYTHON ?= python3
3
4README_TEMPLATE = templates/README_DOCKERHUB.md
5
6TEMPLATE_FILES = $(README_TEMPLATE) \
7 templates/channels_message.md \
8 templates/common_usage.md \
9 templates/header.md
10
11all: all-doc
12
13all-doc: clean-doc readme examples
14
15templates/%.md:
16 wget -nv https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/templates/plain/$@ -O $@
17
18readme: $(TEMPLATE_FILES)
19 mv -v $(README_TEMPLATE) templates/README.md
20 $(PYTHON) $(RENDERDOWN) templates/README.md > README.md
21
22examples:
23 $(PYTHON) $(RENDERDOWN) templates/apache2-deployment.yml > examples/apache2-deployment.yml
24 $(PYTHON) $(RENDERDOWN) templates/docker-compose.yml > examples/docker-compose.yml
25
26clean: clean-doc
27
28clean-doc:
29 rm -fv $(TEMPLATE_FILES) README.md examples/apache2-deployment.yml examples/docker-compose.yml
30
31.PHONY: examples readme clean clean-doc all all-doc
diff --git a/README.md b/README.md
index 495cd2f..2d96fd9 100644
--- a/README.md
+++ b/README.md
@@ -1,141 +1,89 @@
1# Apache2 | Ubuntu1# Apache2 | Ubuntu
22
3Current Apache2 Docker Image from Ubuntu. Receives security updates and rolls to newer Apache2 or Ubuntu LTS. This repository is exempted from per-user rate limits. For [LTS Docker Image](https://ubuntu.com/security/docker-images) versions of this image, see `lts/apache2`.
4
5
3## About Apache26## About Apache2
47
5The Apache HTTP Server Project's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet. Read more on the [apache2 website](https://httpd.apache.org/).8The Apache HTTP Server Project's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet. Read more on the [apache2 website](https://httpd.apache.org/).
69
7## Tags
810
9* `2.4.41-focal`, `2.4.41`, `2.4-focal`, `2.4`, `2-focal`, `2`, `focal`, `beta` - **/!\ this is a beta release**11## Tags and Architectures
12![LTS](https://assets.ubuntu.com/v1/0a5ff561-LTS%402x.png?h=17)
13Up to 5 years free security maintenance `from lts/apache2`.
14
15![ESM](https://assets.ubuntu.com/v1/572f3fbd-ESM%402x.png?h=17)
16Up to 10 years customer security maintenance `from store/canonical/apache2`.
1017
11## Architectures supported18_Tags in italics are not available in ubuntu/apache2 but are shown here for completeness._
19
20| Channel Tag | | | Currently | Architectures |
21|---|---|---|---|---|
22| **`2.4-20.04_beta`**    | | | Apache2 2.4.41 on Ubuntu 20.04 LTS | `amd64`, `arm64`, `ppc64el`, `s390x` |
23| _`track_risk`_ |
24
25Channel tag shows the most stable channel for that track ordered `stable`, `candidate`, `beta`, `edge`. More risky channels are always implicitly available. So if `beta` is listed, you can also pull `edge`. If `candidate` is listed, you can pull `beta` and `edge`. When `stable` is listed, all four are available. Images are guaranteed to progress through the sequence `edge`, `beta`, `candidate` before `stable`.
1226
13* `amd64`, `arm64`, `ppc64el`, `s390x`
1427
15## Usage28## Usage
1629
17### Docker CLI30Launch this image locally:
1831
32```sh
33docker run -d --name apache2-container -e TZ=UTC -p 8080:80 ubuntu/apache2:2.4-20.04_beta
19```34```
20$ docker run -d --name apache2 -p 8080:80 -e TZ=UTC ubuntu/apache2:edge35Access your Apache2 server at `http://localhost:8080`.
21```
22
23You can now point your browser to http://localhost:8080/ and verify that it works.
2436
25#### Parameters37#### Parameters
2638
27| Parameter | Description |39| Parameter | Description |
28|---|---|40|---|---|
29| `-e TZ=UTC` | Timezone. |41| `-e TZ=UTC` | Timezone. |
42| `-p 8080:80` | Expose Apache2 on `localhost:8080`. |
30| `-v /local/path/to/website:/var/www/html` | Mount and serve a local website. |43| `-v /local/path/to/website:/var/www/html` | Mount and serve a local website. |
31| `-p 8080:80` | Expose apache2 on `localhost:8080`. |44| `-v /path/to/apache2.conf:/etc/apache2/apache2.conf` | Local [configuration file](https://httpd.apache.org/docs/2.4/) `apache2.conf` (try [this example](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf)). |
32| `-v /my/config/apache2.conf:/etc/apache2/apache2.conf` | Mount a local configuration `apache2.conf` (download this [example file](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf)). |45
33| `-v /local/path/to/website.conf:/etc/apache2/sites-enabled/website.conf` | Mount and serve a local website, usually as a `VirtualHost`. |
3446
35#### Testing/Debugging47#### Testing/Debugging
3648
37In case you need to debug what is happening with the container you can run `docker logs <name_of_the_container>`. To get access to an interactive shell run:49To debug the container:
3850
51```sh
52docker logs -f apache2-container
39```53```
40$ docker exec -it <name_of_the_container> /bin/bash
41```
42
43### Deploy with Kubernetes
4454
45You can use your favorite Kubernetes distribution; if you don't have one, consider [installing MicroK8s](https://microk8s.io/).55To get an interactive shell:
46
47With microk8s running, enable the `dns` and `storage` add-ons:
4856
49```sh57```sh
50$ microk8s enable dns storage58docker exec -it apache2-container /bin/bash
51```59```
5260
53```sh
54$ microk8s kubectl create configmap apache2-config --from-file=apache2=config/apache2.conf
55```
5661
57Use the sample deployment yaml provided [here](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/apache2-deployment.yml). You will also need to download the contents of the `html` directory [here](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/html)62## Deploy with Kubernetes
58
59<details>
60 <summary>Apply the `apache2-deployment.yml` (click to expand)</summary>
61
62```yaml
63# apache2-deployment.yml
64---
65apiVersion: apps/v1
66kind: Deployment
67metadata:
68 name: apache2-deployment
69spec:
70 replicas: 1
71 selector:
72 matchLabels:
73 app: apache2
74 template:
75 metadata:
76 labels:
77 app: apache2
78 spec:
79 containers:
80 - name: apache2
81 image: ubuntu/apache2:edge
82 volumeMounts:
83 - name: apache2-config-volume
84 mountPath: /etc/apache2/apache2.conf
85 subPath: apache2.conf
86 - name: apache2-config-volume
87 mountPath: /srv/www/index.html
88 subPath: index.html
89 ports:
90 - containerPort: 80
91 name: apache2
92 protocol: TCP
93 volumes:
94 - name: apache2-config-volume
95 configMap:
96 name: apache2-config
97 items:
98 - key: apache2
99 path: apache2.conf
100 - key: apache2-site
101 path: index.html
102---
103apiVersion: v1
104kind: Service
105metadata:
106 name: apache2-service
107spec:
108 type: NodePort
109 selector:
110 app: apache2
111 ports:
112 - protocol: TCP
113 port: 80
114 targetPort: 80
115 nodePort: 30080
116 name: apache
117```
118</details>
11963
120```64Works with any Kubernetes; if you don't have one, we recommend you [install MicroK8s](https://microk8s.io/) and `microk8s.enable dns storage` then `snap alias microk8s.kubectl kubectl`.
121$ microk8s kubectl apply -f apache2-deployment.yml
122```
12365
124You will now be able to connect to the Apache server on `localhost:30080`.66Download
67[apache2.conf](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf), [index.html](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/html/index.html) and
68[apache2-deployment.yml](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/apache2-deployment.yml) and set `containers.apache2.image` in `apache2-deployment.yml` to your chosen channel tag (e.g. `ubuntu/apache2:2.4-20.04_beta`), then:
12569
126## Bugs and Features request70```sh
71kubectl create configmap apache2-config --from-file=apache2=apache2.conf --from-file=apache2-site=index.html
72kubectl apply -f apache2-deployment.yml
73```
74
75You will now be able to connect to the apache2 server on `http://localhost:30080`.
12776
128If you find a bug in our image or want to request a specific feature file a bug here:77## Bugs and feature requests
12978
130https://bugs.launchpad.net/ubuntu-docker-images/+filebug79If you find a bug in our image or want to request a specific feature, please file a bug here:
13180
132In the title of the bug add `apache2: <reason>`.81[https://bugs.launchpad.net/ubuntu-docker-images/+filebug](https://bugs.launchpad.net/ubuntu-docker-images/+filebug)
13382
134Make sure to include:83Please title the bug "`apache2: <issue summary>`". Make sure to include the digest of the image you are using, from:
13584
136* The digest of the image you are using, you can find it using this command replacing `<tag>` with the one you used to run the image:
137```sh85```sh
138$ docker images --no-trunc --quiet ubuntu/apache2:<tag>86docker images --no-trunc --quiet ubuntu/apache2:<tag>
139```87```
140* Reproduction steps for the deployment88
141* If it is a feature request, please provide as much detail as possible89
diff --git a/data/apache2.yaml b/data/apache2.yaml
142new file mode 10064490new file mode 100644
index 0000000..e95c47f
--- /dev/null
+++ b/data/apache2.yaml
@@ -0,0 +1,43 @@
1application: Apache2
2main: true
3repo: apache2
4description: >
5 The Apache HTTP Server Project's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet. Read more on the [apache2 website](https://httpd.apache.org/).
6version: 2.4.41
7base: Ubuntu 20.04 LTS
8architectures:
9 - amd64
10 - arm64
11 - ppc64el
12 - s390x
13docker:
14 parameters:
15 - -p 8080:80
16 access: Access your Apache2 server at `http://localhost:8080`.
17parameters:
18 - type: -e
19 value: TZ=UTC
20 description: Timezone.
21 - type: -p
22 value: 8080:80
23 description: Expose Apache2 on `localhost:8080`.
24 - type: -v
25 value: /local/path/to/website:/var/www/html
26 description: Mount and serve a local website.
27 - type: -v
28 value: /path/to/apache2.conf:/etc/apache2/apache2.conf
29 description: Local [configuration file](https://httpd.apache.org/docs/2.4/) `apache2.conf` (try [this example](https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf)).
30debug:
31 - nothing
32microk8s:
33 configmap:
34 files:
35 - key: apache2
36 name: apache2.conf
37 link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf
38 - key: apache2-site
39 name: index.html
40 link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/html/index.html
41 deploy:
42 link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/apache2-deployment.yml
43 access: You will now be able to connect to the apache2 server on `http://localhost:30080`.
diff --git a/examples/apache2-deployment.yml b/examples/apache2-deployment.yml
index 6715f11..7f217a6 100644
--- a/examples/apache2-deployment.yml
+++ b/examples/apache2-deployment.yml
@@ -15,7 +15,7 @@ spec:
15 spec:15 spec:
16 containers:16 containers:
17 - name: apache217 - name: apache2
18 image: ubuntu/apache2:edge18 image: ubuntu/apache2:latest
19 volumeMounts:19 volumeMounts:
20 - name: apache2-config-volume20 - name: apache2-config-volume
21 mountPath: /etc/apache2/apache2.conf21 mountPath: /etc/apache2/apache2.conf
@@ -51,3 +51,4 @@ spec:
51 targetPort: 8051 targetPort: 80
52 nodePort: 3008052 nodePort: 30080
53 name: apache53 name: apache
54
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
index a27b6bc..24575c5 100644
--- a/examples/docker-compose.yml
+++ b/examples/docker-compose.yml
@@ -2,9 +2,10 @@ version: '2'
22
3services:3services:
4 apache2:4 apache2:
5 image: ubuntu/apache2:edge5 image: ubuntu/apache2:latest
6 ports:6 ports:
7 - 8080:807 - 8080:80
8 volumes:8 volumes:
9 - ./config/apache2.conf:/etc/apache2/apache2.conf:ro9 - ./config/apache2.conf:/etc/apache2/apache2.conf:ro
10 - ./config/html:/srv/www:ro10 - ./config/html:/srv/www:ro
11
diff --git a/templates/apache2-deployment.yml b/templates/apache2-deployment.yml
11new file mode 10064412new file mode 100644
index 0000000..daa623d
--- /dev/null
+++ b/templates/apache2-deployment.yml
@@ -0,0 +1,56 @@
1<%
2 baserepo='ubuntu'
3%>\
4---
5apiVersion: apps/v1
6kind: Deployment
7metadata:
8 name: apache2-deployment
9spec:
10 replicas: 1
11 selector:
12 matchLabels:
13 app: apache2
14 template:
15 metadata:
16 labels:
17 app: apache2
18 spec:
19 containers:
20 - name: apache2
21 image: ${baserepo}/apache2:latest
22 volumeMounts:
23 - name: apache2-config-volume
24 mountPath: /etc/apache2/apache2.conf
25 subPath: apache2.conf
26 - name: apache2-config-volume
27 mountPath: /srv/www/index.html
28 subPath: index.html
29 ports:
30 - containerPort: 80
31 name: apache2
32 protocol: TCP
33 volumes:
34 - name: apache2-config-volume
35 configMap:
36 name: apache2-config
37 items:
38 - key: apache2
39 path: apache2.conf
40 - key: apache2-site
41 path: index.html
42---
43apiVersion: v1
44kind: Service
45metadata:
46 name: apache2-service
47spec:
48 type: NodePort
49 selector:
50 app: apache2
51 ports:
52 - protocol: TCP
53 port: 80
54 targetPort: 80
55 nodePort: 30080
56 name: apache
diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml
0new file mode 10064457new file mode 100644
index 0000000..6c5c92f
--- /dev/null
+++ b/templates/docker-compose.yml
@@ -0,0 +1,13 @@
1<%
2 baserepo='ubuntu'
3%>\
4version: '2'
5
6services:
7 apache2:
8 image: ${baserepo}/apache2:latest
9 ports:
10 - 8080:80
11 volumes:
12 - ./config/apache2.conf:/etc/apache2/apache2.conf:ro
13 - ./config/html:/srv/www:ro

Subscribers

People subscribed via source and target branches

to all changes: