forked from images/gitea-image-forge
Add unit image
This commit is contained in:
parent
3359631596
commit
b1ef3914c6
15
images/unit/Dockerfile.template
Normal file
15
images/unit/Dockerfile.template
Normal file
@ -0,0 +1,15 @@
|
||||
FROM {{ registry }}{{ alt_image }}:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y unit curl tzdata; \
|
||||
rm -f /var/cache/apt/archives/*.rpm \
|
||||
/var/cache/apt/*.bin \
|
||||
/var/lib/apt/lists/*.*
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
13
images/unit/README.md
Normal file
13
images/unit/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
dockerfiles-alt-unit
|
||||
======================
|
||||
|
||||
ALT dockerfile for unit.
|
||||
|
||||
Copy Dockerfile somewhere and build the image:
|
||||
`$ docker build --rm -t <username>/unit .`
|
||||
|
||||
And launch the unit container:
|
||||
`docker run -it -p 80:80 <username>/unit`
|
||||
|
||||
It could be test via:
|
||||
`curl localhost:80`
|
40
images/unit/entrypoint.sh
Executable file
40
images/unit/entrypoint.sh
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh -eu
|
||||
|
||||
# Use bash to debug startup errors
|
||||
if [ "${1-}" = bash ]; then
|
||||
exec bash
|
||||
fi
|
||||
|
||||
configure_unit() {
|
||||
cat <<'EOF' > config.json
|
||||
{
|
||||
"listeners": {
|
||||
"*:80": {
|
||||
"pass": "routes"
|
||||
}
|
||||
},
|
||||
"routes": [
|
||||
{
|
||||
"action": {
|
||||
"share": "/srv/www/html$uri",
|
||||
"chroot": "/srv/www/html"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
mkdir -p /srv/www/html
|
||||
echo '<html><body><h1>It works!</h1></body></html>' > /srv/www/html/index.html
|
||||
|
||||
while ! curl --unix-socket /var/run/unit/control.sock http://localhost; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
curl -f -X PUT --data-binary @config.json \
|
||||
--unix-socket /var/run/unit/control.sock \
|
||||
http://localhost/config
|
||||
}
|
||||
|
||||
configure_unit &
|
||||
|
||||
unitd --no-daemon
|
Loading…
Reference in New Issue
Block a user