Add unit image

This commit is contained in:
Mikhail Gordeev 2022-07-29 17:26:37 +03:00
parent 3359631596
commit b1ef3914c6
3 changed files with 68 additions and 0 deletions

View 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
View 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
View 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