building .deb packages (#13)
ben/sudoisbot/pipeline/head This commit looks good Details

Co-authored-by: Ben Kristinsson <ben@sudo.is>
Reviewed-on: #13
main
ben 3 months ago
parent fd8d1b5f52
commit 1d907ebfbd

@ -18,11 +18,16 @@ RUN apt-get update && \
mkdir -p /opt/${REPO_NAME} && \
chown -R -v ${USER_NAME}. /opt/${REPO_NAME}
USER ${USER_NAME}
WORKDIR /home/${USER_NAME}
ENV PATH="/home/${USER_NAME}/.local/bin:${PATH}"
FROM base as builder
RUN apt-get update && \
apt-get install -y ruby ruby-dev rubygems && \
apt-get autoremove && \
apt-get autoclean && \
gem install --no-document fpm
USER ${USER_NAME}
ARG PIP_REPO_URL="https://git.sudo.is/api/packages/ben/pypi"
ARG PIP_REPO_NAME="gitea"
WORKDIR /opt/${REPO_NAME}
@ -34,6 +39,9 @@ RUN python3 -m pip install poetry --pre && \
echo "repositories configured for poetry:" && \
python3 -m poetry config repositories && \
poetry self -V
# python3 -m poetry config cache-dir "/usr/local/virtualenvs" && \
COPY --chown=${USER_NAME} .flake8 poetry.lock pyproject.toml /opt/${REPO_NAME}/
# install dependencies with poetry and then freeze them in a file, so
@ -56,10 +64,17 @@ RUN poetry run pytest && \
# because this way we dont need to deal with permissions
RUN poetry build --no-interaction
COPY --chown=${USERNAME} deb /opt/${REPO_NAME}/deb/
COPY --chown=${USERNAME} scripts/build/build-deb.sh /usr/local/bin/build-deb.sh
RUN /usr/local/bin/build-deb.sh
RUN dpkg -I dist/sudoisbot_*.deb && dpkg -c dist/sudoisbot_*.deb
ENTRYPOINT ["poetry"]
CMD ["build"]
FROM base as final
USER ${USER_NAME}
COPY --chown=${USER_NAME} --from=builder /opt/${REPO_NAME}/requirements.txt /opt/${REPO_NAME}/
RUN python3 -m pip install -r /opt/${REPO_NAME}/requirements.txt && \
python3 -m pip cache purge && \

2
Jenkinsfile vendored

@ -1,7 +1,7 @@
@Library('shared-jenkins-pipelines') _
// source:
// https://git.sudo.is/ben/shared-jenkins-pipelines/src/branch/main/vars/pythondocker.groovy
// https://git.sudo.is/ben/shared-jenkins-pipelines/src/branch/main/vars/poetry.groovy
poetry(
docker: true,

@ -0,0 +1,9 @@
#!/bin/bash
systemctl daemon-reload
if `systemctl is-active --quiet sudoisbot@temp_pub`; then
echo -n "restarting temp_pub..."
service sudoisbot@temp_pub restart
echo "ok"
fi

@ -0,0 +1,14 @@
[Unit]
Description=sudoisbot
After=syslog.target
[Service]
User=sudoisbot
Group=sudoisbot
WorkingDirectory=/var/lib/sudoisbot
ExecStart=/usr/local/bin/sudoisbot %I
Restart=on-failure
RestartSec=6
[Install]
WantedBy=multi-user.target

@ -0,0 +1,29 @@
#!/bin/bash
set -e
DEPS="-d python3.10"
pypoetry_venv_path=$(poetry env info -p)
version=$(poetry version -s)
pwd=$(pwd)
echo "pypoetry_venv_path: $pypoetry_venv_path"
echo "version: $version"
fpm \
-a all \
-t deb \
$DEPS \
-n ${REPO_NAME} \
-v ${version} \
--config-files /etc/systemd/system/sudoisbot@.service \
--after-install deb/after-install.sh \
-s dir \
$pypoetry_venv_path \
$pypoetry_venv_path=/usr/local/virtualenvs/${REPO_NAME} \
$(pwd)/deb/etc/systemd/system/=/etc/systemd/system/
mv -v ${REPO_NAME}_*.deb dist/
Loading…
Cancel
Save