Skip to content

Commit 7c7b699

Browse files
committed
Split into two images: 'run' and 'test'.
1 parent ee76a8c commit 7c7b699

File tree

5 files changed

+67
-22
lines changed

5 files changed

+67
-22
lines changed

Dockerfile

+44-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
1-
##########################################
2-
FROM jrottenberg/ffmpeg:3.2-ubuntu AS base
3-
##########################################
4-
RUN apt-get update && apt-get install -y python3.8 pip git
1+
###########################################
2+
FROM jrottenberg/ffmpeg:4.1-ubuntu AS base
3+
###########################################
4+
ENV PYTHONDONTWRITEBYTECODE=1 \
5+
PYTHONUNBUFFERED=1 \
6+
PIP_NO_CACHE_DIR=off \
7+
PIP_DISABLE_PIP_VERSION_CHECK=on \
8+
POETRY_NO_INTERACTION=1
59

6-
#################
10+
RUN apt-get update && \
11+
apt-get install -y python3.8 pip git && \
12+
apt-get install --no-install-recommends -y curl build-essential && \
13+
apt-get clean
14+
15+
##################
716
FROM base AS apg
8-
#################
9-
ARG APG_DIR=/audio_program_generator/
17+
##################
1018
WORKDIR /
11-
COPY ./entry.sh entry.sh
12-
1319
RUN mkdir /apg && \
14-
git clone https://github.com/jeffwright13/audio_program_generator.git && \
15-
pip install poetry && \
16-
cd $APG_DIR && \
17-
poetry install --no-dev
20+
git clone https://github.com/jeffwright13/audio_program_generator.git
21+
22+
###################
23+
FROM apg AS poetry
24+
###################
25+
ARG APG_SRC_DIR=/audio_program_generator
26+
WORKDIR $APG_SRC_DIR
27+
RUN pip install --no-cache-dir poetry
1828

1929
###################
20-
FROM apg AS runtime
30+
FROM poetry AS run
2131
###################
32+
ARG APG_SRC_DIR=/audio_program_generator
33+
WORKDIR $APG_SRC_DIR
34+
COPY ./entry-run.sh entry-run.sh
35+
RUN cd $APG_SRC_DIR && \
36+
poetry install --no-interaction --no-dev
37+
38+
ENTRYPOINT ["/bin/bash"]
39+
CMD ["/audio_program_generator/entry-run.sh"]
40+
41+
####################
42+
FROM poetry AS test
43+
####################
44+
ARG APG_SRC_DIR=/audio_program_generator
45+
COPY ./entry-test.sh ./entry-test.sh
46+
RUN cd $APG_SRC_DIR && \
47+
poetry install --no-interaction
48+
RUN ln -s $(poetry env info --path) /var/my-venv
49+
RUN echo 'source /var/my-venv/bin/activate' >> ~/.bashrc
50+
2251
ENTRYPOINT ["/bin/bash"]
23-
CMD ["/entry.sh"]
52+
CMD ["/audio_program_generator/entry-test.sh"]

Makefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
DIR:=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
2-
build:
3-
docker build --tag apg .
2+
3+
build-all: build-run build-test
4+
5+
build-run:
6+
docker build --target run --tag apg-run .
47
run:
5-
docker run --rm -it -v "$(DIR)"/apgfiles:/audio_program_generator/apgfiles apg
8+
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles apg-run
9+
10+
build-test:
11+
docker build --target test --tag apg-test .
12+
test:
13+
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles apg-test

apg-shell.sh

-2
This file was deleted.

entry.sh renamed to entry-run.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
export VIRTUAL_ENV_DISABLE_PROMPT=1
33
cd /audio_program_generator || exit
44
echo --------------------------------------
5-
echo Type apg to create an audio program.
6-
echo Type exit to quit.
5+
echo Type 'apg' to create an audio program.
6+
echo Type 'exit' to quit.
77
echo --------------------------------------
8+
source ~/.bashrc
89
poetry shell

entry-test.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set +x
3+
export VIRTUAL_ENV_DISABLE_PROMPT=1
4+
cd /audio_program_generator || exit
5+
echo --------------------------------------
6+
echo Running tests...
7+
echo --------------------------------------
8+
source /var/my-venv/bin/activate
9+
pytest -v --html=tests/results/report.html --self-contained-html

0 commit comments

Comments
 (0)