Skip to content

Commit

Permalink
fix dirpaths for container
Browse files Browse the repository at this point in the history
  • Loading branch information
Headary committed Dec 26, 2023
1 parent d86d3a2 commit eab860d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions astrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ ARG DOCKER_USER=astrid
RUN useradd -m $DOCKER_USER

# change workdir
WORKDIR /data/
WORKDIR /app

# install python requirements
COPY requirements.txt .
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
16 changes: 7 additions & 9 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -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 <příkaz>`
- stáhnutí `fykosak/buildtools` (potřeba před prvním buildem repozitáře): `docker exec -it astrid podman pull docker.io/fykosak/buildtools`
16 changes: 16 additions & 0 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion docker/start.sh

This file was deleted.

0 comments on commit eab860d

Please sign in to comment.