changing dragon bot to use multi stage builds. im so cool

This commit is contained in:
Luke Robles 2020-03-18 12:34:54 -07:00
parent e6f80bb63e
commit d0dec59f30
4 changed files with 38 additions and 10 deletions

View File

@ -1,8 +1,15 @@
FROM python:3.6-alpine3.9 FROM python:3.6-buster AS builder
RUN apt-get update && apt-get install -y gcc python-pip
ADD app/requirements.txt /requirements.txt ADD app/requirements.txt /requirements.txt
RUN pip install -U pip && pip install -r requirements.txt
#stage 2
FROM python:3.6-alpine3.9
RUN apk update && \ RUN apk update && \
apk add --no-cache docker && \ apk add --no-cache docker
pip install -U pip && \
pip install -r requirements.txt COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages
ADD app /app ADD app /app
CMD python /app/dragon-bot.py CMD python /app/dragon-bot.py

View File

@ -1,10 +1,15 @@
FROM python:3.6.2-alpine3.6 FROM python:3.6-buster AS builder
RUN apt-get update && apt-get install -y gcc python-pip
ADD app/requirements.txt /requirements.txt ADD app/requirements.txt /requirements.txt
RUN pip install -U pip && pip install -r requirements.txt
#stage 2
FROM python:3.6-alpine3.9
RUN apk update && \ RUN apk update && \
apk add --no-cache vim docker build-base && \ apk add --no-cache docker
pip install -U pip && \
pip install pylint && \ COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages
pip install -r requirements.txt
ADD app /app ADD app /app
RUN printf "\n\nTesting your python code for errors\n\n" && \ RUN printf "\n\nTesting your python code for errors\n\n" && \
@ -12,3 +17,5 @@ RUN printf "\n\nTesting your python code for errors\n\n" && \
WORKDIR /app WORKDIR /app
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n" RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n"
CMD python /app/dragon-bot.py

14
Dockerfile-test-env.bak Normal file
View File

@ -0,0 +1,14 @@
FROM python:3.6.2-alpine3.6
ADD app/requirements.txt /requirements.txt
RUN apk update && \
apk add --no-cache vim docker build-base && \
pip install -U pip && \
pip install pylint && \
pip install -r requirements.txt
ADD app /app
RUN printf "\n\nTesting your python code for errors\n\n" && \
pylint -E /app/*.py
WORKDIR /app
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n"

View File

@ -6,4 +6,4 @@ gTTS-token
pyowm pyowm
requests requests
wikipedia wikipedia
wolframalpha wolframalpha