diff --git a/astrid/__init__.py b/astrid/__init__.py index 8ce06e1..f985eef 100644 --- a/astrid/__init__.py +++ b/astrid/__init__.py @@ -68,8 +68,8 @@ def _sendMail(self, reponame, message): from configparser import ConfigParser -REPOS_INI = '~/.astrid/repos.ini' -CONFIG_INI = '~/.astrid/config.ini' +REPOS_INI = '/app/config/repos.ini' +CONFIG_INI = '/app/config/config.ini' repos = ConfigParser() repos.read(os.path.expanduser(REPOS_INI)) diff --git a/config.ini.sample b/config.ini.sample index 0c4c376..b8dcfe9 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -7,7 +7,7 @@ tools.auth_basic.on: True tools.auth_basic.realm: 'Astrid authorization' tools.auth_basic.checkpassword: cherrypy.lib.auth_basic.checkpassword_dict({'user': 'passwd'}) tools.expires.sec = 0 -repodir = 'data' +repodir = '/app/repos' [/style.css] tools.staticfile.on = True diff --git a/docker/Dockerfile b/docker/Dockerfile index 6924cc3..d42c42e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,7 +8,7 @@ ARG DOCKER_USER=astrid RUN useradd -m $DOCKER_USER # change workdir -WORKDIR /data/ +WORKDIR /app # install python requirements COPY requirements.txt . @@ -16,11 +16,10 @@ RUN pip install -r requirements.txt # install astrid under astrid user COPY . . -RUN chown -R $DOCKER_USER:$DOCKER_USER /data +RUN chown -R $DOCKER_USER:$DOCKER_USER /app USER $DOCKER_USER -#RUN ./build.sh # create config directory -RUN mkdir ~/.astrid +RUN mkdir /app/config /app/repos ENTRYPOINT ./docker/entrypoint.sh diff --git a/docker/README.md b/docker/README.md index bf40931..c0f9fa9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,11 +1,9 @@ # Docker container -## Build - - in root directory: - ``` - podman build . -f docker/Dockerfile --tag astrid - ``` -## Run -``` -podman run --rm --name astrid --volume "./config:/home/astrid/.astrid" --volume "./ssh:/home/astrid/.ssh" -p 8080:8080 astrid -``` +## Vývoj +- nutnost: nainstalovaný `docker` a `docker-compose-plugin` +- vytvoření aktuální image: `docker compose build` (potřeba spustit před prvním spuštěním) +- vytvoření mount složek (případný `chown` pro vlastnění správným uživatelem): `mkdir config containers repos ssh` +- spuštění: `docker compose up` +- spouštění příkazů uvnitř dockeru: `docker exec -it astrid
` + - stáhnutí `fykosak/buildtools` (potřeba před prvním buildem repozitáře): `docker exec -it astrid podman pull docker.io/fykosak/buildtools` diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml new file mode 100644 index 0000000..c26fbbd --- /dev/null +++ b/docker/docker-compose.prod.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + astrid: + image: ghcr.io/fykosak/astrid:master + restart: on-failure:3 + container_name: astrid + environment: + TZ: 'Europe/Prague' + privileged: true # needed for containers + volumes: + - ./config:/home/astrid/.astrid + - ./ssh:/home/astrid/.ssh + - ./containers:/home/astrid/.local/share/containers + - ./repos:/data/repos + user: 1000:1000 # expects the main user with uid:pid diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2106062..27ec522 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,10 +12,10 @@ services: TZ: 'Europe/Prague' privileged: true # needed for containers volumes: - - ./config:/home/astrid/.astrid + - ./config:/app/config - ./ssh:/home/astrid/.ssh - ./containers:/home/astrid/.local/share/containers - - ./repos:/data/repos + - ./repos:/app/repos ports: - 8080:8080 # opened port mapping, not needed with proxy user: 1000:1000 # expects the main user with uid:pid diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ab04fc7..720f64e 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,4 +1,4 @@ -cp -n /data/config.ini.sample /home/astrid/.astrid/config.ini -cp -n /data/repos.ini.sample /home/astrid/.astrid/repos.ini +cp -n /app/config.ini.sample /app/config/config.ini +cp -n /app/repos.ini.sample /app/config/repos.ini python3 -u ./main diff --git a/docker/start.sh b/docker/start.sh deleted file mode 100755 index a36d856..0000000 --- a/docker/start.sh +++ /dev/null @@ -1 +0,0 @@ -docker run --rm --name astrid --volume "./config:/home/astrid/.astrid" --volume "./ssh:/home/astrid/.ssh" --volume "./containers:/home/astrid/.local/share/containers" --volume "./repos:/data/repos" -p 8080:8080 --privileged astrid