Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding docker build #42

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
targets/esp32
targets/cli/build
**/.git
**/node_modules
**/CMakeCache.txt
**/CMakeFiles
**/build
**/Makefile
.DS_Store
euphonium/protos
targets/cli/build
targets/esp32/app/dependencies.lock
web/yarn.lock
.idea
cmake-build-debug
build/
scripts-version
wifi.config.json
euphonium/scripts/*.json
euphonium/scripts/configuration/*.json
targets/esp32/app/spiffs/*
py/
*.d
.cache
.cache/
authBlob.json
77 changes: 77 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FROM ubuntu:22.10 AS base

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
git ca-certificates golang protobuf-compiler \
libavahi-compat-libdnssd-dev libasound2-dev libasound2-plugins \
cmake build-essential libssl-dev nodejs curl yarn python3-pip iproute2 \
pulseaudio pulseaudio-utils sudo

# Install yarn
#RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \
# && echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
# && apt-get install yarn

## Make and install PortAudio
ADD http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz /tmp/
RUN cd tmp \
&& tar zxvf pa_stable_v190700_20210406.tgz \
&& cd portaudio/ \
&& ./configure && make -j$(nproc) && make install

WORKDIR /project

ADD requirements.txt .

## install python dependencies
RUN pip install -r requirements.txt

FROM base AS builder

# Add everything to WORKDIR
ADD . .

#RUN git clone https://github.com/feelfreelinux/euphonium.git \
# && cd euphonium \
# && git submodule update --init --recursive \
## install python dependencies
# && pip install -r requirements.txt \
# && pip install python3-protobuf




# cmake fix
#RUN sed -i 's/VERSION 3.18/VERSION 3.16/' CMakeLists.txt
WORKDIR /project/targets/cli

ENV HTTP_PORT=8080
RUN mkdir -p build \
&& cd build \
&& cmake .. -D HTTP_SERVER_PORT=${HTTP_PORT} \
&& make -j$(nproc)

## Create runtime image from here

FROM builder AS runtime

ENV UNAME euphonium

RUN export UNAME=$UNAME UID=1000 GID=1000 && \
mkdir -p "/home/${UNAME}" && \
echo "${UNAME}:x:${UID}:${GID}:${UNAME} User,,,:/home/${UNAME}:/bin/bash" >> /etc/passwd && \
echo "${UNAME}:x:${UID}:" >> /etc/group && \
mkdir -p /etc/sudoers.d && \
echo "${UNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${UNAME} && \
chmod 0440 /etc/sudoers.d/${UNAME} && \
chown ${UID}:${GID} -R /home/${UNAME} && \
gpasswd -a ${UNAME} audio

COPY docker/pulse-client.conf /etc/pulse/client.conf

USER $UNAME
ENV HOME /home/$UNAME

EXPOSE 8080
CMD ["/project/targets/cli/build/euphoniumcli"]
9 changes: 9 additions & 0 deletions docker/pulse-client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Connect to the host's server using the mounted UNIX socket
default-server = unix:/run/user/1000/pulse/native

# Prevent a server running in the container
autospawn = no
daemon-binary = /bin/true

# Prevent the use of shared memory
enable-shm = false