1
0
Fork 0

ci: build container

Dustin 2022-08-01 18:29:08 -05:00
parent acf281c0ab
commit b21f6b0853
7 changed files with 100 additions and 0 deletions

20
ci/Jenkinsfile vendored
View File

@ -51,5 +51,25 @@ pipeline {
}
}
}
stage('Build Container') {
steps {
container('podman') {
dir('container') {
sh '. ../ci/build-container.sh'
}
}
}
}
stage('Publish Container') {
steps {
container('podman') {
dir('container') {
sh '. ../ci/publish-container.sh'
}
}
}
}
}
}

5
ci/build-container.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh -ex
cp -r ui/dist ui
cp -r svc/dist wheels
podman build -t hudctrl:${BUILD_NUMBER} .

3
ci/publish-container.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh -ex
podman push hudctrl:${BUILD_ID} registry.pyrocufflink.blue/hudctrl:${BUILD_ID}

19
container/Containerfile Normal file
View File

@ -0,0 +1,19 @@
FROM docker.io/python:3.10-slim AS build
COPY wheels /tmp/wheels
COPY requirements.txt /tmp
RUN python -m venv /usr/local/hudctrl
RUN /usr/local/hudctrl/bin/python -m \
pip install -f /tmp/wheels -r /tmp/requirements.txt
COPY ui /usr/local/hudctrl/ui
FROM docker.io/python:3.10-slim
RUN apt-get update && \
apt-get install -y nginx tini && \
rm -rf /var/cache/apt /var/lib/apt
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/local/hudctrl /usr/local/hudctrl
COPY run.sh /
CMD ["tini", "--", "/run.sh"]

43
container/nginx.conf Normal file
View File

@ -0,0 +1,43 @@
# vim: set sw=4 ts=4 sts=4 et :
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stderr;
error_log /var/log/nginx/error.log;
gzip on;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/local/hudctrl/ui;
index index.html;
location /api/ {
proxy_pass http://127.0.0.1:8000/;
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
set_real_ip_from ::/0;
real_ip_recursive on;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded-For $realip_remote_addr;
}
}
}

View File

@ -0,0 +1,3 @@
gunicorn
hudctrl
uvicorn

7
container/run.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
nginx || exit $?
exec /usr/local/hudctrl/bin/gunicorn \
-k uvicorn.workers.UvicornWorker \
hudctrl.api:app