1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Automated all distribution files

This commit is contained in:
krateng 2022-03-09 21:53:42 +01:00
parent 7b89d227a3
commit e3dc401ccf
16 changed files with 160 additions and 96 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
*
!/maloja
!Dockerfile
!/requirements.txt
!/pyproject.toml
!/README.md
!/LICENSE

View File

@ -1,21 +1,21 @@
# Contributor: Johannes Krattenmacher <maloja@dev.krateng.ch>
# Maintainer: Johannes Krattenmacher <maloja@dev.krateng.ch>
pkgname=maloja
pkgver=2.14.6
pkgver=3.0.0-dev
pkgrel=0
pkgdesc="Scrobble statistics server"
pkgdesc="Self-hosted music scrobble database"
url="https://github.com/krateng/maloja"
arch="noarch"
license="GPL-3.0"
depends="python3 tzdata vips"
pkgusers=$pkgname
pkggroups=$pkgname
depends_dev="gcc python3-dev libxml2-dev libxslt-dev libffi-dev libc-dev py3-pip linux-headers py3-build"
depends_dev="gcc python3-dev libxml2-dev libxslt-dev libffi-dev libc-dev py3-pip linux-headers"
makedepends="$depends_dev"
source="
maloja-$pkgver.tar.gz::https://github.com/krateng/maloja/archive/refs/tags/v$pkgver.tar.gz
$pkgname-$pkgver.tar.gz::https://github.com/krateng/maloja/archive/refs/tags/v$pkgver.tar.gz
"
builddir="$srcdir"/maloja-$pkgver
builddir="$srcdir"/$pkgname-$pkgver
@ -26,10 +26,11 @@ build() {
}
package() {
mkdir -p /etc/maloja || return 1
mkdir -p /var/lib/maloja || return 1
mkdir -p /var/cache/maloja || return 1
mkdir -p /var/logs/maloja || return 1
mkdir -p /etc/$pkgname || return 1
mkdir -p /var/lib/$pkgname || return 1
mkdir -p /var/cache/$pkgname || return 1
mkdir -p /var/logs/$pkgname || return 1
}
sha512sums="a674eaaaa248fc2b315514d79f9a7a0bac6aa1582fe29554d9176e8b551e8aa3aa75abeebdd7713e9e98cc987e7bd57dc7a5e9a2fb85af98b9c18cb54de47bf7 maloja-${pkgver}.tar.gz"
# TODO
sha512sums="a674eaaaa248fc2b315514d79f9a7a0bac6aa1582fe29554d9176e8b551e8aa3aa75abeebdd7713e9e98cc987e7bd57dc7a5e9a2fb85af98b9c18cb54de47bf7 $pkgname-${pkgver}.tar.gz"

View File

@ -6,23 +6,21 @@ FROM python:3-alpine
WORKDIR /usr/src/app
# this should change rarely, can be cached
COPY ./requirements.txt ./requirements.txt
# Copy project into dir
COPY . .
# Install everything before copying rest of the project, can be cached
RUN \
# Build dependencies (This will pipe all packages from the file)
sed 's/#.*//' ./install/dependencies_build.txt | xargs apk add --no-cache --virtual .build-deps && \
# Runtime dependencies (Same)
sed 's/#.*//' ./install/dependencies_run.txt | xargs apk add --no-cache && \
# Python dependencies
pip3 install --no-cache-dir -r requirements.txt && \
# Local project install
pip3 install /usr/src/app && \
# Remove build dependencies
apk del .build-deps
apk add --no-cache --virtual .build-deps gcc python3-dev libxml2-dev libxslt-dev libffi-dev libc-dev py3-pip linux-headers && \
apk add --no-cache python3 tzdata vips && \
pip3 install --no-cache-dir -r requirements.txt && \
apk del .build-deps
# expected behavior for a default setup is for maloja to "just work"
COPY . .
RUN pip3 install /usr/src/app
# Docker-specific configuration and default to IPv4
ENV MALOJA_SKIP_SETUP=yes
ENV MALOJA_HOST=0.0.0.0

View File

@ -1,36 +0,0 @@
FROM python:3-alpine
# Based on the work of Jonathan Boeckel <jonathanboeckel1996@gmail.com>
# https://gitlab.com/Joniator/docker-maloja
# https://github.com/Joniator
WORKDIR /usr/src/app
# Copy project into dir
COPY ./install ./install
COPY ./requirements.txt ./requirements.txt
# Build dependencies (This will pipe all packages from the file)
RUN sed 's/#.*//' ./install/dependencies_build.txt | xargs apk add --no-cache --virtual .build-deps
# Runtime dependencies (Same)
RUN sed 's/#.*//' ./install/dependencies_run.txt | xargs apk add --no-cache
# Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Local project install
COPY ./maloja ./maloja
COPY ./pyproject.toml ./pyproject.toml
COPY ./README.md ./README.md
COPY ./LICENSE ./LICENSE
RUN pip3 install /usr/src/app
# Remove build dependencies
RUN apk del .build-deps
# expected behavior for a default setup is for maloja to "just work"
ENV MALOJA_SKIP_SETUP=yes
ENV MALOJA_HOST=0.0.0.0
EXPOSE 42010
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint
ENTRYPOINT ["maloja", "run"]

View File

@ -1,31 +0,0 @@
FROM python:3-alpine
# Based on the work of Jonathan Boeckel <jonathanboeckel1996@gmail.com>
# https://gitlab.com/Joniator/docker-maloja
# https://github.com/Joniator
ARG MALOJA_RELEASE
WORKDIR /usr/src/app
# Copy needed information
COPY ./install ./install
RUN \
# Build dependencies (This will pipe all packages from the file)
sed 's/#.*//' ./install/dependencies_build.txt | xargs apk add --no-cache --virtual .build-deps && \
# Runtime dependencies (Same)
sed 's/#.*//' ./install/dependencies_run.txt | xargs apk add --no-cache && \
# PyPI install
pip3 install malojaserver==$MALOJA_RELEASE && \
# Remove build dependencies
apk del .build-deps
# expected behavior for a default setup is for maloja to "just work"
ENV MALOJA_SKIP_SETUP=yes
ENV MAGICK_HOME=/usr
EXPOSE 42010
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint
ENTRYPOINT ["maloja", "run"]

View File

@ -1,2 +1,2 @@
docker build -t maloja-dev . -f Dockerfile-dev
docker run -p 42010:42010 -v $PWD/testdata:/mlj -e MALOJA_DATA_DIRECTORY=/mlj maloja-dev
docker build -t maloja . -f Dockerfile
docker run --rm -p 42010:42010 -v $PWD/testdata:/mlj -e MALOJA_DATA_DIRECTORY=/mlj maloja

View File

@ -0,0 +1,36 @@
# Contributor: Johannes Krattenmacher <maloja@dev.krateng.ch>
# Maintainer: Johannes Krattenmacher <maloja@dev.krateng.ch>
pkgname={{ tool.flit.module.name }}
pkgver={{ project.version }}
pkgrel=0
pkgdesc="{{ project.description }}"
url="{{ project.urls.homepage }}"
arch="noarch"
license="GPL-3.0"
depends="{{ tool.osreqs.alpine.run | join(' ') }}"
pkgusers=$pkgname
pkggroups=$pkgname
depends_dev="{{ tool.osreqs.alpine.build | join(' ') }}"
makedepends="$depends_dev"
source="
$pkgname-$pkgver.tar.gz::{{ project.urls.repository }}/archive/refs/tags/v$pkgver.tar.gz
"
builddir="$srcdir"/$pkgname-$pkgver
build() {
cd $builddir
python3 -m build .
pip3 install dist/*.tar.gz
}
package() {
mkdir -p /etc/$pkgname || return 1
mkdir -p /var/lib/$pkgname || return 1
mkdir -p /var/cache/$pkgname || return 1
mkdir -p /var/logs/$pkgname || return 1
}
# TODO
sha512sums="a674eaaaa248fc2b315514d79f9a7a0bac6aa1582fe29554d9176e8b551e8aa3aa75abeebdd7713e9e98cc987e7bd57dc7a5e9a2fb85af98b9c18cb54de47bf7 $pkgname-${pkgver}.tar.gz"

View File

@ -0,0 +1,29 @@
FROM python:3-alpine
# Based on the work of Jonathan Boeckel <jonathanboeckel1996@gmail.com>
# https://gitlab.com/Joniator/docker-maloja
# https://github.com/Joniator
WORKDIR /usr/src/app
# this should change rarely, can be cached
COPY ./requirements.txt ./requirements.txt
# Install everything before copying rest of the project, can be cached
RUN \
apk add --no-cache --virtual .build-deps {{ tool.osreqs.alpine.build | join(' ') }} && \
apk add --no-cache {{ tool.osreqs.alpine.run | join(' ') }} && \
pip3 install --no-cache-dir -r requirements.txt && \
apk del .build-deps
COPY . .
RUN pip3 install /usr/src/app
# Docker-specific configuration and default to IPv4
ENV MALOJA_SKIP_SETUP=yes
ENV MALOJA_HOST=0.0.0.0
EXPOSE 42010
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint
ENTRYPOINT ["maloja", "run"]

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
apk add \
{{ tool.osreqs.alpine.build | join(' \\\n\t') }} \
{{ tool.osreqs.alpine.run | join(' \\\n\t') }}
pip3 install wheel
pip3 install malojaserver

View File

@ -0,0 +1,3 @@
{% for dep in project.dependencies -%}
{{ dep }}
{% endfor %}

View File

@ -0,0 +1,3 @@
{% for dep in project['optional-dependencies'].full -%}
{{ dep }}
{% endfor %}

24
dev/update_files.py Normal file
View File

@ -0,0 +1,24 @@
import toml
import os
import jinja2
from pprint import pprint
with open("pyproject.toml") as filed:
data = toml.load(filed)
templatedir = "./dev/templates"
for templatefile in os.listdir(templatedir):
srcfile = os.path.join(templatedir,templatefile)
trgfile = os.path.join(".",templatefile.replace(".jinja",""))
with open(srcfile) as templatefiled:
template = jinja2.Template(templatefiled.read())
result = template.render(**data)
with open(trgfile,"w") as filed:
filed.write(result)
filed.write('\n')

View File

@ -1,14 +1,14 @@
#!/usr/bin/env bash
apk add \
python3 \
python3-dev \
gcc \
python3-dev \
libxml2-dev \
libxslt-dev \
libffi-dev \
libc-dev \
py3-pip \
linux-headers \
python3 \
tzdata \
vips
pip3 install wheel

View File

@ -33,6 +33,11 @@ dependencies = [
"python-datauri>=1.1.0"
]
[project.optional-dependencies]
full = [
"pyvips>=2.1"
]
[project.scripts]
maloja = "maloja.proccontrol.control:main"
@ -42,3 +47,20 @@ build-backend = "flit_core.buildapi"
[tool.flit.module]
name = "maloja"
[tool.osreqs.alpine]
build =[
"gcc",
"python3-dev",
"libxml2-dev",
"libxslt-dev",
"libffi-dev",
"libc-dev",
"py3-pip",
"linux-headers"
]
run = [
"python3",
"tzdata",
"vips"
]

View File

@ -1,6 +1,6 @@
bottle>=0.12.16
waitress>=1.3
doreah>=1.7.4
doreah>=1.7.4, <2
nimrodel>=0.7.0
setproctitle>=1.1.10
jinja2>=2.11
@ -9,3 +9,4 @@ css_html_js_minify>=2.5.5
psutil>=5.8.0
sqlalchemy>=1.4
python-datauri>=1.1.0

View File

@ -1 +1,2 @@
pyvips>=2.1