Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:improve-template into ~ubuntu-docker-images/ubuntu-docker-images/+git/apache2:edge
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) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lucas Kanashiro | Approve | ||
Canonical Server | Pending | ||
Review via email:
|
Commit message
Description of the change
Start improving the template mechanism. This is a WIP.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Durigan Junior (sergiodj) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Durigan Junior (sergiodj) wrote : | # |
FWIW, this will be affected by Valentin's MP 394365.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lucas Kanashiro (lucaskanashiro) wrote : | # |
LGTM, +1.
Preview Diff
1 | diff --git a/.gitignore b/.gitignore |
2 | new file mode 100644 |
3 | index 0000000..2a4e9c0 |
4 | --- /dev/null |
5 | +++ b/.gitignore |
6 | @@ -0,0 +1,4 @@ |
7 | +templates/README.md |
8 | +templates/channels_message.md |
9 | +templates/common_usage.md |
10 | +templates/header.md |
11 | diff --git a/HACKING.md b/HACKING.md |
12 | index d929d68..cfa9b96 100644 |
13 | --- a/HACKING.md |
14 | +++ b/HACKING.md |
15 | @@ -21,3 +21,31 @@ $ docker build -t ubuntu/apache2:test . |
16 | you can also check the README.md file. |
17 | |
18 | * If everything goes well submit a merge proposal. |
19 | + |
20 | +# Generating the documentation |
21 | + |
22 | +The documentation (`README.md` and some files in the `examples/` |
23 | +directory) are generated using templates. In order to do that, you |
24 | +need to follow some steps. |
25 | + |
26 | +``` |
27 | +$ pwd |
28 | +~/work/apache2 |
29 | +$ cd .. |
30 | +$ git clone https://github.com/misterw97/RenderDown |
31 | +$ cd apache2 |
32 | +$ make all-doc |
33 | +``` |
34 | + |
35 | +If you already have the `RenderDown` repository cloned somewhere else, |
36 | +you can tell `make` about it: |
37 | + |
38 | +``` |
39 | +$ RENDERDOWN=/path/to/renderdown.py make all-doc |
40 | +``` |
41 | + |
42 | +# Hacking the documentation templates |
43 | + |
44 | +You can find some of the templates used to generated the documentation |
45 | +inside the `templates/` directory. You can also look at the `data/` |
46 | +directory for the files used to feed the templates. |
47 | diff --git a/Makefile b/Makefile |
48 | new file mode 100644 |
49 | index 0000000..6a49a17 |
50 | --- /dev/null |
51 | +++ b/Makefile |
52 | @@ -0,0 +1,31 @@ |
53 | +RENDERDOWN ?= ../RenderDown/renderdown.py |
54 | +PYTHON ?= python3 |
55 | + |
56 | +README_TEMPLATE = templates/README_DOCKERHUB.md |
57 | + |
58 | +TEMPLATE_FILES = $(README_TEMPLATE) \ |
59 | + templates/channels_message.md \ |
60 | + templates/common_usage.md \ |
61 | + templates/header.md |
62 | + |
63 | +all: all-doc |
64 | + |
65 | +all-doc: clean-doc readme examples |
66 | + |
67 | +templates/%.md: |
68 | + wget -nv https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/templates/plain/$@ -O $@ |
69 | + |
70 | +readme: $(TEMPLATE_FILES) |
71 | + mv -v $(README_TEMPLATE) templates/README.md |
72 | + $(PYTHON) $(RENDERDOWN) templates/README.md > README.md |
73 | + |
74 | +examples: |
75 | + $(PYTHON) $(RENDERDOWN) templates/apache2-deployment.yml > examples/apache2-deployment.yml |
76 | + $(PYTHON) $(RENDERDOWN) templates/docker-compose.yml > examples/docker-compose.yml |
77 | + |
78 | +clean: clean-doc |
79 | + |
80 | +clean-doc: |
81 | + rm -fv $(TEMPLATE_FILES) README.md examples/apache2-deployment.yml examples/docker-compose.yml |
82 | + |
83 | +.PHONY: examples readme clean clean-doc all all-doc |
84 | diff --git a/README.md b/README.md |
85 | index 495cd2f..2d96fd9 100644 |
86 | --- a/README.md |
87 | +++ b/README.md |
88 | @@ -1,141 +1,89 @@ |
89 | # Apache2 | Ubuntu |
90 | |
91 | +Current 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`. |
92 | + |
93 | + |
94 | ## About Apache2 |
95 | |
96 | 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/). |
97 | |
98 | -## Tags |
99 | |
100 | -* `2.4.41-focal`, `2.4.41`, `2.4-focal`, `2.4`, `2-focal`, `2`, `focal`, `beta` - **/!\ this is a beta release** |
101 | +## Tags and Architectures |
102 | +![LTS](https://assets.ubuntu.com/v1/0a5ff561-LTS%402x.png?h=17) |
103 | +Up to 5 years free security maintenance `from lts/apache2`. |
104 | + |
105 | +![ESM](https://assets.ubuntu.com/v1/572f3fbd-ESM%402x.png?h=17) |
106 | +Up to 10 years customer security maintenance `from store/canonical/apache2`. |
107 | |
108 | -## Architectures supported |
109 | +_Tags in italics are not available in ubuntu/apache2 but are shown here for completeness._ |
110 | + |
111 | +| Channel Tag | | | Currently | Architectures | |
112 | +|---|---|---|---|---| |
113 | +| **`2.4-20.04_beta`** | | | Apache2 2.4.41 on Ubuntu 20.04 LTS | `amd64`, `arm64`, `ppc64el`, `s390x` | |
114 | +| _`track_risk`_ | |
115 | + |
116 | +Channel 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`. |
117 | |
118 | -* `amd64`, `arm64`, `ppc64el`, `s390x` |
119 | |
120 | ## Usage |
121 | |
122 | -### Docker CLI |
123 | +Launch this image locally: |
124 | |
125 | +```sh |
126 | +docker run -d --name apache2-container -e TZ=UTC -p 8080:80 ubuntu/apache2:2.4-20.04_beta |
127 | ``` |
128 | -$ docker run -d --name apache2 -p 8080:80 -e TZ=UTC ubuntu/apache2:edge |
129 | -``` |
130 | - |
131 | -You can now point your browser to http://localhost:8080/ and verify that it works. |
132 | +Access your Apache2 server at `http://localhost:8080`. |
133 | |
134 | #### Parameters |
135 | |
136 | | Parameter | Description | |
137 | |---|---| |
138 | | `-e TZ=UTC` | Timezone. | |
139 | +| `-p 8080:80` | Expose Apache2 on `localhost:8080`. | |
140 | | `-v /local/path/to/website:/var/www/html` | Mount and serve a local website. | |
141 | -| `-p 8080:80` | Expose apache2 on `localhost:8080`. | |
142 | -| `-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)). | |
143 | -| `-v /local/path/to/website.conf:/etc/apache2/sites-enabled/website.conf` | Mount and serve a local website, usually as a `VirtualHost`. | |
144 | +| `-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)). | |
145 | + |
146 | |
147 | #### Testing/Debugging |
148 | |
149 | -In 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: |
150 | +To debug the container: |
151 | |
152 | +```sh |
153 | +docker logs -f apache2-container |
154 | ``` |
155 | -$ docker exec -it <name_of_the_container> /bin/bash |
156 | -``` |
157 | - |
158 | -### Deploy with Kubernetes |
159 | |
160 | -You can use your favorite Kubernetes distribution; if you don't have one, consider [installing MicroK8s](https://microk8s.io/). |
161 | - |
162 | -With microk8s running, enable the `dns` and `storage` add-ons: |
163 | +To get an interactive shell: |
164 | |
165 | ```sh |
166 | -$ microk8s enable dns storage |
167 | +docker exec -it apache2-container /bin/bash |
168 | ``` |
169 | |
170 | -```sh |
171 | -$ microk8s kubectl create configmap apache2-config --from-file=apache2=config/apache2.conf |
172 | -``` |
173 | |
174 | -Use 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) |
175 | - |
176 | -<details> |
177 | - <summary>Apply the `apache2-deployment.yml` (click to expand)</summary> |
178 | - |
179 | -```yaml |
180 | -# apache2-deployment.yml |
181 | ---- |
182 | -apiVersion: apps/v1 |
183 | -kind: Deployment |
184 | -metadata: |
185 | - name: apache2-deployment |
186 | -spec: |
187 | - replicas: 1 |
188 | - selector: |
189 | - matchLabels: |
190 | - app: apache2 |
191 | - template: |
192 | - metadata: |
193 | - labels: |
194 | - app: apache2 |
195 | - spec: |
196 | - containers: |
197 | - - name: apache2 |
198 | - image: ubuntu/apache2:edge |
199 | - volumeMounts: |
200 | - - name: apache2-config-volume |
201 | - mountPath: /etc/apache2/apache2.conf |
202 | - subPath: apache2.conf |
203 | - - name: apache2-config-volume |
204 | - mountPath: /srv/www/index.html |
205 | - subPath: index.html |
206 | - ports: |
207 | - - containerPort: 80 |
208 | - name: apache2 |
209 | - protocol: TCP |
210 | - volumes: |
211 | - - name: apache2-config-volume |
212 | - configMap: |
213 | - name: apache2-config |
214 | - items: |
215 | - - key: apache2 |
216 | - path: apache2.conf |
217 | - - key: apache2-site |
218 | - path: index.html |
219 | ---- |
220 | -apiVersion: v1 |
221 | -kind: Service |
222 | -metadata: |
223 | - name: apache2-service |
224 | -spec: |
225 | - type: NodePort |
226 | - selector: |
227 | - app: apache2 |
228 | - ports: |
229 | - - protocol: TCP |
230 | - port: 80 |
231 | - targetPort: 80 |
232 | - nodePort: 30080 |
233 | - name: apache |
234 | -``` |
235 | -</details> |
236 | +## Deploy with Kubernetes |
237 | |
238 | -``` |
239 | -$ microk8s kubectl apply -f apache2-deployment.yml |
240 | -``` |
241 | +Works 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`. |
242 | |
243 | -You will now be able to connect to the Apache server on `localhost:30080`. |
244 | +Download |
245 | +[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 |
246 | +[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: |
247 | |
248 | -## Bugs and Features request |
249 | +```sh |
250 | +kubectl create configmap apache2-config --from-file=apache2=apache2.conf --from-file=apache2-site=index.html |
251 | +kubectl apply -f apache2-deployment.yml |
252 | +``` |
253 | + |
254 | +You will now be able to connect to the apache2 server on `http://localhost:30080`. |
255 | |
256 | -If you find a bug in our image or want to request a specific feature file a bug here: |
257 | +## Bugs and feature requests |
258 | |
259 | -https://bugs.launchpad.net/ubuntu-docker-images/+filebug |
260 | +If you find a bug in our image or want to request a specific feature, please file a bug here: |
261 | |
262 | -In the title of the bug add `apache2: <reason>`. |
263 | +[https://bugs.launchpad.net/ubuntu-docker-images/+filebug](https://bugs.launchpad.net/ubuntu-docker-images/+filebug) |
264 | |
265 | -Make sure to include: |
266 | +Please title the bug "`apache2: <issue summary>`". Make sure to include the digest of the image you are using, from: |
267 | |
268 | -* 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: |
269 | ```sh |
270 | -$ docker images --no-trunc --quiet ubuntu/apache2:<tag> |
271 | +docker images --no-trunc --quiet ubuntu/apache2:<tag> |
272 | ``` |
273 | -* Reproduction steps for the deployment |
274 | -* If it is a feature request, please provide as much detail as possible |
275 | + |
276 | + |
277 | diff --git a/data/apache2.yaml b/data/apache2.yaml |
278 | new file mode 100644 |
279 | index 0000000..e95c47f |
280 | --- /dev/null |
281 | +++ b/data/apache2.yaml |
282 | @@ -0,0 +1,43 @@ |
283 | +application: Apache2 |
284 | +main: true |
285 | +repo: apache2 |
286 | +description: > |
287 | + 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/). |
288 | +version: 2.4.41 |
289 | +base: Ubuntu 20.04 LTS |
290 | +architectures: |
291 | + - amd64 |
292 | + - arm64 |
293 | + - ppc64el |
294 | + - s390x |
295 | +docker: |
296 | + parameters: |
297 | + - -p 8080:80 |
298 | + access: Access your Apache2 server at `http://localhost:8080`. |
299 | +parameters: |
300 | + - type: -e |
301 | + value: TZ=UTC |
302 | + description: Timezone. |
303 | + - type: -p |
304 | + value: 8080:80 |
305 | + description: Expose Apache2 on `localhost:8080`. |
306 | + - type: -v |
307 | + value: /local/path/to/website:/var/www/html |
308 | + description: Mount and serve a local website. |
309 | + - type: -v |
310 | + value: /path/to/apache2.conf:/etc/apache2/apache2.conf |
311 | + 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)). |
312 | +debug: |
313 | + - nothing |
314 | +microk8s: |
315 | + configmap: |
316 | + files: |
317 | + - key: apache2 |
318 | + name: apache2.conf |
319 | + link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/apache2.conf |
320 | + - key: apache2-site |
321 | + name: index.html |
322 | + link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/config/html/index.html |
323 | + deploy: |
324 | + link: https://git.launchpad.net/~canonical-server/ubuntu-docker-images/+git/apache2/plain/examples/apache2-deployment.yml |
325 | + access: You will now be able to connect to the apache2 server on `http://localhost:30080`. |
326 | diff --git a/examples/apache2-deployment.yml b/examples/apache2-deployment.yml |
327 | index 6715f11..7f217a6 100644 |
328 | --- a/examples/apache2-deployment.yml |
329 | +++ b/examples/apache2-deployment.yml |
330 | @@ -15,7 +15,7 @@ spec: |
331 | spec: |
332 | containers: |
333 | - name: apache2 |
334 | - image: ubuntu/apache2:edge |
335 | + image: ubuntu/apache2:latest |
336 | volumeMounts: |
337 | - name: apache2-config-volume |
338 | mountPath: /etc/apache2/apache2.conf |
339 | @@ -51,3 +51,4 @@ spec: |
340 | targetPort: 80 |
341 | nodePort: 30080 |
342 | name: apache |
343 | + |
344 | diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml |
345 | index a27b6bc..24575c5 100644 |
346 | --- a/examples/docker-compose.yml |
347 | +++ b/examples/docker-compose.yml |
348 | @@ -2,9 +2,10 @@ version: '2' |
349 | |
350 | services: |
351 | apache2: |
352 | - image: ubuntu/apache2:edge |
353 | + image: ubuntu/apache2:latest |
354 | ports: |
355 | - 8080:80 |
356 | volumes: |
357 | - ./config/apache2.conf:/etc/apache2/apache2.conf:ro |
358 | - ./config/html:/srv/www:ro |
359 | + |
360 | diff --git a/templates/apache2-deployment.yml b/templates/apache2-deployment.yml |
361 | new file mode 100644 |
362 | index 0000000..daa623d |
363 | --- /dev/null |
364 | +++ b/templates/apache2-deployment.yml |
365 | @@ -0,0 +1,56 @@ |
366 | +<% |
367 | + baserepo='ubuntu' |
368 | +%>\ |
369 | +--- |
370 | +apiVersion: apps/v1 |
371 | +kind: Deployment |
372 | +metadata: |
373 | + name: apache2-deployment |
374 | +spec: |
375 | + replicas: 1 |
376 | + selector: |
377 | + matchLabels: |
378 | + app: apache2 |
379 | + template: |
380 | + metadata: |
381 | + labels: |
382 | + app: apache2 |
383 | + spec: |
384 | + containers: |
385 | + - name: apache2 |
386 | + image: ${baserepo}/apache2:latest |
387 | + volumeMounts: |
388 | + - name: apache2-config-volume |
389 | + mountPath: /etc/apache2/apache2.conf |
390 | + subPath: apache2.conf |
391 | + - name: apache2-config-volume |
392 | + mountPath: /srv/www/index.html |
393 | + subPath: index.html |
394 | + ports: |
395 | + - containerPort: 80 |
396 | + name: apache2 |
397 | + protocol: TCP |
398 | + volumes: |
399 | + - name: apache2-config-volume |
400 | + configMap: |
401 | + name: apache2-config |
402 | + items: |
403 | + - key: apache2 |
404 | + path: apache2.conf |
405 | + - key: apache2-site |
406 | + path: index.html |
407 | +--- |
408 | +apiVersion: v1 |
409 | +kind: Service |
410 | +metadata: |
411 | + name: apache2-service |
412 | +spec: |
413 | + type: NodePort |
414 | + selector: |
415 | + app: apache2 |
416 | + ports: |
417 | + - protocol: TCP |
418 | + port: 80 |
419 | + targetPort: 80 |
420 | + nodePort: 30080 |
421 | + name: apache |
422 | diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml |
423 | new file mode 100644 |
424 | index 0000000..6c5c92f |
425 | --- /dev/null |
426 | +++ b/templates/docker-compose.yml |
427 | @@ -0,0 +1,13 @@ |
428 | +<% |
429 | + baserepo='ubuntu' |
430 | +%>\ |
431 | +version: '2' |
432 | + |
433 | +services: |
434 | + apache2: |
435 | + image: ${baserepo}/apache2:latest |
436 | + ports: |
437 | + - 8080:80 |
438 | + volumes: |
439 | + - ./config/apache2.conf:/etc/apache2/apache2.conf:ro |
440 | + - ./config/html:/srv/www:ro |
This is now ready for review. The commit message explains it all.