Skip to content

Instantly share code, notes, and snippets.

@kstrauss
Created April 26, 2019 20:29
Show Gist options
  • Save kstrauss/4c6ee9511a60f1b3ea33945df231effd to your computer and use it in GitHub Desktop.
Save kstrauss/4c6ee9511a60f1b3ea33945df231effd to your computer and use it in GitHub Desktop.
python example dockerfile for linux
#from alpine:latest as base
from python:3.7.3-alpine as base
from base as builder
RUN apk add --no-cache python3 python3-dev py-pip build-base
# create directory to copy files to
RUN mkdir /install/
WORKDIR /install
# copy the files that should have come from git
copy requirements.txt requirements.txt
# go ahead and install the python modules that also came from git
RUN pip install --install-option="--prefix=/install" -r requirements.txt
FROM base
copy --from=builder /install /usr/local
RUN mkdir /app/
COPY numpyTest.py /app/numpyTest.py
# create a simple python script
#RUN echo print("Hello World from python from a container!") > c:\hello.py
# establish what command will run when the docker run command is executed
CMD ["python", "/app/numpyTest.py"]
import numpy as np
print ("start")
a = np.arange(15).reshape(3,5)
print (a)
print ("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment