Skip to content

Commit

Permalink
Refactored DOckerfile and Makefile to improve execution experience.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Wright committed Nov 14, 2021
1 parent 182e7e1 commit d0176aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ ARG APG_SRC_DIR=/audio_program_generator
WORKDIR $APG_SRC_DIR
RUN pip install --no-cache-dir poetry

###################
FROM poetry AS run
###################
######################
FROM poetry AS apg-run
######################
ARG APG_SRC_DIR=/audio_program_generator
WORKDIR $APG_SRC_DIR
COPY ./entry-run.sh entry-run.sh
RUN cd $APG_SRC_DIR && \
poetry install --no-interaction --no-dev

ENTRYPOINT ["/bin/bash"]
CMD ["/audio_program_generator/entry-run.sh"]
COPY pyproject.toml ./
COPY poetry.lock ./
RUN poetry install --no-interaction --no-dev
ENTRYPOINT ["/bin/bash", "-c", "poetry run apg \"$@\"", "--"]

####################
FROM poetry AS test
####################
#######################
FROM poetry AS apg-test
#######################
ARG APG_SRC_DIR=/audio_program_generator
COPY ./entry-test.sh ./entry-test.sh
RUN cd $APG_SRC_DIR && \
Expand Down
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
DIR:=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
NAME:=$(shell grep -e "^name\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs)
VERSION:=$(shell grep -e "^version\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs)

build-all: build-run build-test
apg-build:
docker build --target apg-run --tag $(NAME):$(VERSION) .

build-run:
docker build --target run --tag apg-run .
run:
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles apg-run
apg:
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles $(NAME):$(VERSION) ${args}

apg-build-test:
docker build --target apg-test --tag apg-test:$(VERSION) .

build-test:
docker build --target test --tag apg-test .
test:
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles apg-test
docker run --rm -it -v $(DIR)/apgfiles:/audio_program_generator/apgfiles apg-test:$(VERSION)

.PHONY : clean
clean:
docker container rm -f $(NAME):$(VERSION)
docker image rm -f $(NAME):$(VERSION)
9 changes: 0 additions & 9 deletions entry-run.sh

This file was deleted.

0 comments on commit d0176aa

Please sign in to comment.