Fossil SCM

Added a few more "container-*" targets to the main makefile to simplify the examples in the containers doc and make the resulting images and containers easier to manage.

wyoung 2022-12-03 11:37 trunk
Commit b7edb5f1c5b09364f519fc03914f39f0419611e4e49e2f00c7ef57bfcc70cd7f
2 files changed +37 -24 +6 -8
+37 -24
--- Makefile.in
+++ Makefile.in
@@ -119,36 +119,49 @@
119119
@AUTOREMAKE@
120120
touch @builddir@/Makefile
121121
122122
# Container stuff
123123
SRCTB := src-@[email protected]
124
+IMGVER := fossil:@FOSSIL_CI_PFX@
125
+CNTVER := fossil-@FOSSIL_CI_PFX@
126
+container:
127
+ docker image inspect $(IMGVER) > /dev/null 2>&1 || \
128
+ $(MAKE) container-image
129
+ docker container inspect $(CNTVER) > /dev/null 2>&1 || \
130
+ docker create \
131
+ --name $(CNTVER) \
132
+ --cap-drop AUDIT_WRITE \
133
+ --cap-drop CHOWN \
134
+ --cap-drop FSETID \
135
+ --cap-drop KILL \
136
+ --cap-drop MKNOD \
137
+ --cap-drop NET_BIND_SERVICE \
138
+ --cap-drop NET_RAW \
139
+ --cap-drop SETFCAP \
140
+ --cap-drop SETPCAP \
141
+ --publish 8080:8080 \
142
+ $(DCFLAGS) $(IMGVER)
143
+
144
+container-clean:
145
+ -docker container kill $(CNTVER)
146
+ -docker container rm $(CNTVER)
147
+ -docker image rm $(IMGVER)
148
+
124149
container-image:
125150
$(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB)
126151
docker buildx build \
127
- --tag fossil:@FOSSIL_CI_PFX@ \
152
+ --load \
153
+ --tag $(IMGVER) \
128154
--build-arg FSLURL=$(SRCTB) \
129155
$(DBFLAGS) @srcdir@
130156
rm -f $(SRCTB)
131157
132
-container-run:
133
- docker image inspect fossil:@FOSSIL_CI_PFX@ > /dev/null 2>&1 || \
134
- $(MAKE) container-image
135
- docker run \
136
- --name fossil-@FOSSIL_CI_PFX@ \
137
- --cap-drop AUDIT_WRITE \
138
- --cap-drop CHOWN \
139
- --cap-drop FSETID \
140
- --cap-drop KILL \
141
- --cap-drop MKNOD \
142
- --cap-drop NET_BIND_SERVICE \
143
- --cap-drop NET_RAW \
144
- --cap-drop SETFCAP \
145
- --cap-drop SETPCAP \
146
- --detach --publish 8080:8080 \
147
- $(DRFLAGS) fossil:@FOSSIL_CI_PFX@
148
- @sleep 1 # decrease likelihood of logging race condition
149
- docker container logs fossil-@FOSSIL_CI_PFX@
150
-
151
-container-clean:
152
- -docker container kill fossil-@FOSSIL_CI_PFX@
153
- -docker container rm fossil-@FOSSIL_CI_PFX@
154
- -docker image rm fossil:@FOSSIL_CI_PFX@
158
+container-run container-start: container
159
+ docker start $(DSFLAGS) $(CNTVER)
160
+ @sleep 1 # decrease likelihood of logging race condition
161
+ docker container logs $(CNTVER)
162
+
163
+container-stop:
164
+ docker stop $(CNTVER)
165
+
166
+container-version:
167
+ @echo $(CNTVER)
155168
--- Makefile.in
+++ Makefile.in
@@ -119,36 +119,49 @@
119 @AUTOREMAKE@
120 touch @builddir@/Makefile
121
122 # Container stuff
123 SRCTB := src-@[email protected]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124 container-image:
125 $(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB)
126 docker buildx build \
127 --tag fossil:@FOSSIL_CI_PFX@ \
 
128 --build-arg FSLURL=$(SRCTB) \
129 $(DBFLAGS) @srcdir@
130 rm -f $(SRCTB)
131
132 container-run:
133 docker image inspect fossil:@FOSSIL_CI_PFX@ > /dev/null 2>&1 || \
134 $(MAKE) container-image
135 docker run \
136 --name fossil-@FOSSIL_CI_PFX@ \
137 --cap-drop AUDIT_WRITE \
138 --cap-drop CHOWN \
139 --cap-drop FSETID \
140 --cap-drop KILL \
141 --cap-drop MKNOD \
142 --cap-drop NET_BIND_SERVICE \
143 --cap-drop NET_RAW \
144 --cap-drop SETFCAP \
145 --cap-drop SETPCAP \
146 --detach --publish 8080:8080 \
147 $(DRFLAGS) fossil:@FOSSIL_CI_PFX@
148 @sleep 1 # decrease likelihood of logging race condition
149 docker container logs fossil-@FOSSIL_CI_PFX@
150
151 container-clean:
152 -docker container kill fossil-@FOSSIL_CI_PFX@
153 -docker container rm fossil-@FOSSIL_CI_PFX@
154 -docker image rm fossil:@FOSSIL_CI_PFX@
155
--- Makefile.in
+++ Makefile.in
@@ -119,36 +119,49 @@
119 @AUTOREMAKE@
120 touch @builddir@/Makefile
121
122 # Container stuff
123 SRCTB := src-@[email protected]
124 IMGVER := fossil:@FOSSIL_CI_PFX@
125 CNTVER := fossil-@FOSSIL_CI_PFX@
126 container:
127 docker image inspect $(IMGVER) > /dev/null 2>&1 || \
128 $(MAKE) container-image
129 docker container inspect $(CNTVER) > /dev/null 2>&1 || \
130 docker create \
131 --name $(CNTVER) \
132 --cap-drop AUDIT_WRITE \
133 --cap-drop CHOWN \
134 --cap-drop FSETID \
135 --cap-drop KILL \
136 --cap-drop MKNOD \
137 --cap-drop NET_BIND_SERVICE \
138 --cap-drop NET_RAW \
139 --cap-drop SETFCAP \
140 --cap-drop SETPCAP \
141 --publish 8080:8080 \
142 $(DCFLAGS) $(IMGVER)
143
144 container-clean:
145 -docker container kill $(CNTVER)
146 -docker container rm $(CNTVER)
147 -docker image rm $(IMGVER)
148
149 container-image:
150 $(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB)
151 docker buildx build \
152 --load \
153 --tag $(IMGVER) \
154 --build-arg FSLURL=$(SRCTB) \
155 $(DBFLAGS) @srcdir@
156 rm -f $(SRCTB)
157
158 container-run container-start: container
159 docker start $(DSFLAGS) $(CNTVER)
160 @sleep 1 # decrease likelihood of logging race condition
161 docker container logs $(CNTVER)
162
163 container-stop:
164 docker stop $(CNTVER)
165
166 container-version:
167 @echo $(CNTVER)
 
 
 
 
 
 
 
 
 
 
 
 
 
168
--- www/containers.md
+++ www/containers.md
@@ -39,16 +39,17 @@
3939
The Fossil `Makefile` provides two convenience targets,
4040
“`make container-image`” and “`make container-run`”. The first creates a
4141
versioned container image, and the second does that and then launches a
4242
fresh container based on that image. You can pass extra arguments to the
4343
first command via the Makefile’s `DBFLAGS` variable and to the second
44
-with the `DRFLAGS` variable. (DB is short for “`docker build`”, and DR
45
-is short for “`docker run`”.) To get the custom port setting as in
44
+with the `DCFLAGS` variable. (DB is short for “`docker build`”, and DC
45
+is short for “`docker create`”, a sub-step of the “run” target.)
46
+To get the custom port setting as in
4647
second command above, say:
4748
4849
```
49
- $ make container-run DRFLAGS='-p 9999:8080/tcp'
50
+ $ make container-run DCFLAGS='-p 9999:8080/tcp'
5051
```
5152
5253
Contrast the raw “`docker`” commands above, which create an
5354
_unversioned_ image called `fossil:latest` and from that a container
5455
simply called `fossil`. The unversioned names are more convenient for
@@ -726,18 +727,15 @@
726727
727728
The first configuration step is to convert the Docker container into
728729
a “machine”, as systemd calls it. The easiest method is:
729730
730731
```
731
- $ make container-run
732
- $ docker container export fossil-e119d5983620 |
732
+ $ make container
733
+ $ docker container export $(make container-version) |
733734
machinectl import-tar - myproject
734735
```
735736
736
-Copy the container name from the first step to the second. Yours will
737
-almost certainly be named after a different Fossil commit ID.
738
-
739737
It’s important that the name of the machine you create —
740738
“`myproject`” in this example — matches the base name
741739
of the nspawn configuration file you create as the next step.
742740
Therefore, to extend the example, the following file needs to be
743741
called `/etc/systemd/nspawn/myproject.nspawn`, and it will contain
744742
--- www/containers.md
+++ www/containers.md
@@ -39,16 +39,17 @@
39 The Fossil `Makefile` provides two convenience targets,
40 “`make container-image`” and “`make container-run`”. The first creates a
41 versioned container image, and the second does that and then launches a
42 fresh container based on that image. You can pass extra arguments to the
43 first command via the Makefile’s `DBFLAGS` variable and to the second
44 with the `DRFLAGS` variable. (DB is short for “`docker build`”, and DR
45 is short for “`docker run`”.) To get the custom port setting as in
 
46 second command above, say:
47
48 ```
49 $ make container-run DRFLAGS='-p 9999:8080/tcp'
50 ```
51
52 Contrast the raw “`docker`” commands above, which create an
53 _unversioned_ image called `fossil:latest` and from that a container
54 simply called `fossil`. The unversioned names are more convenient for
@@ -726,18 +727,15 @@
726
727 The first configuration step is to convert the Docker container into
728 a “machine”, as systemd calls it. The easiest method is:
729
730 ```
731 $ make container-run
732 $ docker container export fossil-e119d5983620 |
733 machinectl import-tar - myproject
734 ```
735
736 Copy the container name from the first step to the second. Yours will
737 almost certainly be named after a different Fossil commit ID.
738
739 It’s important that the name of the machine you create —
740 “`myproject`” in this example — matches the base name
741 of the nspawn configuration file you create as the next step.
742 Therefore, to extend the example, the following file needs to be
743 called `/etc/systemd/nspawn/myproject.nspawn`, and it will contain
744
--- www/containers.md
+++ www/containers.md
@@ -39,16 +39,17 @@
39 The Fossil `Makefile` provides two convenience targets,
40 “`make container-image`” and “`make container-run`”. The first creates a
41 versioned container image, and the second does that and then launches a
42 fresh container based on that image. You can pass extra arguments to the
43 first command via the Makefile’s `DBFLAGS` variable and to the second
44 with the `DCFLAGS` variable. (DB is short for “`docker build`”, and DC
45 is short for “`docker create`”, a sub-step of the “run” target.)
46 To get the custom port setting as in
47 second command above, say:
48
49 ```
50 $ make container-run DCFLAGS='-p 9999:8080/tcp'
51 ```
52
53 Contrast the raw “`docker`” commands above, which create an
54 _unversioned_ image called `fossil:latest` and from that a container
55 simply called `fossil`. The unversioned names are more convenient for
@@ -726,18 +727,15 @@
727
728 The first configuration step is to convert the Docker container into
729 a “machine”, as systemd calls it. The easiest method is:
730
731 ```
732 $ make container
733 $ docker container export $(make container-version) |
734 machinectl import-tar - myproject
735 ```
736
 
 
 
737 It’s important that the name of the machine you create —
738 “`myproject`” in this example — matches the base name
739 of the nspawn configuration file you create as the next step.
740 Therefore, to extend the example, the following file needs to be
741 called `/etc/systemd/nspawn/myproject.nspawn`, and it will contain
742

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button