Browse Source

Modify docker image and test it

- instead of copying the code into the image, use a volume to install
  the code. That way if the code changes, there's no need to rebuild
  the image
- add .dockerignore
- modify docker-compose.yml to configure gnunet from a volume and have
  all gnunet data as a volume too
- test the images in the CI in a different job
master
juga 1 year ago
parent
commit
6b8378acbe
6 changed files with 33 additions and 21 deletions
  1. +9
    -0
      .dockerignore
  2. +4
    -15
      .gitlab-ci.yml
  3. +2
    -4
      Dockerfile
  4. +2
    -2
      docker-compose.yml
  5. +7
    -0
      docker/entrypoint.sh
  6. +9
    -0
      docker/test.sh

+ 9
- 0
.dockerignore View File

@ -0,0 +1,9 @@
.gitlab-ci.yml
Dockerfile
docs
tmp
.eggs
.tox
.pytest_cache
*__pycache__*
# docker

+ 4
- 15
.gitlab-ci.yml View File

@ -22,25 +22,14 @@ build:
- docker push $IMAGE
- docker tag $IMAGE $RELEASE_IMAGE
- docker push $RELEASE_IMAGE
only:
changes:
- Dockerfile
- pygnunetrest
- setup.cfg
- setup.py
- tests
test-docker:
stage: test
image: docker/compose
script:
- apk add --no-cache py-pip gcc libffi-dev openssl-dev libc-dev make python3-dev
- pip install docker-compose
- docker-compose up -d
- sleep 3
- echo Runing docker-compose with $RELEASE_IMAGE
# XXX: when there is an official gnunet image that works, replace this
# See https://bugs.gnunet.org/view.php?id=6628
- docker pull registry.gitlab.com/juga0/gnunet:latest
- docker pull $RELEASE_IMAGE || true
- mkdir -p tmp
- cp docker/gnunet.conf tmp/
- docker-compose up -d
- docker exec gnunetrest pytest-3 tests
- /bin/sh ./docker/test.sh

+ 2
- 4
Dockerfile View File

@ -7,11 +7,9 @@ RUN apt update && \
python3-pytest
FROM gnunetrest-deps as gnunetrest
ARG UID=1000
RUN apt update -y && apt install -y telnet netstat-nat iputils-ping procps
RUN addgroup --system gnunetdns && \
addgroup --system gnunet && \
adduser --system --uid $UID gnunet --ingroup gnunet
COPY --chown=gnunet:gnunet . /home/gnunet/pygnunetrest
WORKDIR /home/gnunet/pygnunetrest
RUN python3 setup.py develop
USER gnunet
COPY docker/*.sh /opt/
ENTRYPOINT [ "/opt/entrypoint.sh" ]

+ 2
- 2
docker-compose.yml View File

@ -8,7 +8,8 @@ services:
container_name: gnunet
# Copy a gnunet.conf that enable REST in all interfaces into ./tmp
volumes:
- ./tmp:/home/gnunet/.config
- ./tmp:/home/gnunet
- ./docker/gnunet.conf:/home/gnunet/.config/gnunet.conf
# expose REST port to gnunetrest container
expose:
- 7776
@ -20,7 +21,6 @@ services:
image: ${RELEASE_IMAGE:-gnunet-docker}
environment:
- HOST=gnunet
command: pytest-3 tests
container_name: gnunetrest
volumes:
- .:/home/gnunet/pygnunetrest


+ 7
- 0
docker/entrypoint.sh View File

@ -0,0 +1,7 @@
#!/bin/bash
set -x
python3 setup.py develop
# just to keep the container running.
tail -F /var/log/lastlog

+ 9
- 0
docker/test.sh View File

@ -0,0 +1,9 @@
#!/bin/bash
set -x
mkdir -p tmp
chown 1000.1000 tmp
docker-compose up -d
sleep 3
docker exec gnunetrest pytest-3 tests

Loading…
Cancel
Save