Skip to content

Commit

Permalink
build docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Sep 12, 2017
1 parent 99c4315 commit b71fb70
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 16 deletions.
31 changes: 30 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ workflows:
test__trigger:
jobs:
- test
- trigger_components:
- docker_build_common:
requires:
- test
- docker_build_common_pulseaudio:
requires:
- test
- trigger_components:
requires:
- docker_build_common
- docker_build_common_pulseaudio
filters:
branches:
only: master
Expand Down Expand Up @@ -65,6 +72,28 @@ jobs:
# Useless for now waiting for update from circleCI UI
- store_test_results:
path: pytest/
docker_build_common:
docker:
- image: docker:17.05.0-ce-git
working_directory: ~/repo
steps:
- run:
name: Build Docker based image
command: |
docker build -t tuxeatpi/common:latest -f misc/docker/common/Dockerfile .
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
docker push tuxeatpi/brain:latest
docker_build_common_pulseaudio:
docker:
- image: docker:17.05.0-ce-git
working_directory: ~/repo
steps:
- run:
name: Build Docker pulseaudio image
command: |
docker build -t tuxeatpi/pulseaudio:latest -f misc/docker/pulseaudio/Dockerfile .
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
docker push tuxeatpi/brain:latest
# Missing circle workflow api
trigger_components:
docker:
Expand Down
26 changes: 11 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,24 @@ doc-generate:
cd doc && make html

#######################################
### Localization
### Docker targets
#######################################
lang-scan:
pygettext3.5 --output-dir=tuxeatpi/locale/ -k gtt -va -x tuxeatpi/libs/lang.py tuxeatpi/*.py tuxeatpi/*/*.py tuxeatpi/*/*/*.py
cd tuxeatpi/locale && msgmerge --update --no-fuzzy-matching --backup=off en/LC_MESSAGES/tuxeatpi.po messages.pot
cd tuxeatpi/locale && msgmerge --update --no-fuzzy-matching --backup=off fr/LC_MESSAGES/tuxeatpi.po messages.pot
docker_common_build:
docker build -t tuxeatpi_common -f misc/docker/common/Dockerfile .

lang-gen:
cd tuxeatpi/locale/fr/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo
cd tuxeatpi/locale/en/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo
docker_common_irun:
docker run -it --rm tuxeatpi_common bash

docker_pulseaudio_build:
docker build -t tuxeatpi_pulseaudio -f misc/docker/pulseaudio/Dockerfile .

docker_pulseaudio_irun:
docker run -it --rm tuxeatpi_pulseaudio bash

set-locales:
sudo sed -i 's/# \(en_US.UTF-8 .*\)/\1/g' /etc/locale.gen
sudo sed -i 's/# \(en_CA.UTF-8 .*\)/\1/g' /etc/locale.gen
sudo sed -i 's/# \(fr_FR.UTF-8 .*\)/\1/g' /etc/locale.gen
sudo sed -i 's/# \(fr_CA.UTF-8 .*\)/\1/g' /etc/locale.gen
sudo locale-gen

#######################################
### Test targets
#######################################

test-run: test-syntax test-pytest

test-syntax:
Expand Down
28 changes: 28 additions & 0 deletions misc/docker/common/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.6-stretch

RUN mkdir -p /workdir
RUN mkdir -p /opt/tuxeatpi_common

COPY misc/docker/common/entrypoint.sh /entrypoint.sh

COPY requirements.txt /opt/tuxeatpi_common/requirements.txt
COPY test_requirements.txt /opt/tuxeatpi_common/test_requirements.txt

RUN python --version
RUN apt-get update && \
apt-get install -y --no-install-recommends git gcc && \
apt-get clean && \
pip install -r /opt/tuxeatpi_common/requirements.txt && \
apt-get -y purge gcc git && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY setup.py /opt/tuxeatpi_common/
COPY tuxeatpi_common /opt/tuxeatpi_common/tuxeatpi_common

RUN cd /opt/tuxeatpi_common && \
python setup.py install && \
rm -rf /opt/tuxeatpi_common

WORKDIR /workdir

ENTRYPOINT ["/entrypoint.sh"]
38 changes: 38 additions & 0 deletions misc/docker/common/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -x

# Get tep args
ARGS=$@
# Get tep executable
EXE=$(which tep-$1)

set -e

if [ "$EXE" != "" ]; then
USER_UID=${USER_UID:-1000}
USER_GID=${USER_GID:-1000}

# create user group
if ! getent group tep >/dev/null; then
groupadd -f -g ${USER_GID} tep
fi

# create user with uid and gid matching that of the host user
if ! getent passwd tep >/dev/null; then
adduser --uid ${USER_UID} --gid ${USER_GID} \
--disabled-login \
--gecos 'TuxEatPi' tep

fi
if [ $# == "1" ];
then
exec su tep -c "$EXE -w /workdir -I /intents -D /dialogs"
else
exec su tep -c "$EXE -w /workdir -I /intents -D /dialogs $@"
# OR exec su tep -c "$EXE $ARGS" ????
fi

else
echo "tep-$1 executable not found. Running $1"
exec "$@"
fi
12 changes: 12 additions & 0 deletions misc/docker/pulseaudio/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM tuxeatpi/common


ENV PULSE_SERVER /run/pulse/native

RUN apt-get update && \
apt-get install --no-install-recommends pulseaudio-utils pulseaudio && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/

RUN echo enable-shm=no >> /etc/pulse/client.conf

VOLUME /run/pulse

0 comments on commit b71fb70

Please sign in to comment.