Last active
December 5, 2021 18:04
-
-
Save Majramos/dd68948c82ae66f6556541111a9b5fe8 to your computer and use it in GitHub Desktop.
Setup a python development environment in docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local_pg={"host":"localhost","port": 5432,"database":"local_pg","user":"local_pg","password":"local_pg"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# call the operating system to be used | |
FROM python:3.9.7-slim | |
# Install the linux libraries needed | |
RUN apt-get update | |
# set a directory for the app | |
WORKDIR /devenv | |
# Copy all the necessary files to the container | |
COPY /requirements.txt /devenv | |
# install necessary packages using the requirements.txt | |
RUN pip install -r requirements.txt | |
# launch the notebook as the entrypoint | |
CMD sh -c 'jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --notebook-dir=/devenv --allow-root --NotebookApp.token='' --NotebookApp.password='' ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pandas | |
numpy | |
jupyterlab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define environment name | |
$name = "devenv-test1" | |
# define python version - this should match version set in dockerfile.devenv | |
$version = "py3.9.7" | |
# define the port for this specific environment | |
$port = 5000 | |
# build image of development environment | |
docker build -f dockerfile.devenv -t ${name}:${version} . | |
# run container based on built image | |
docker run -d ` | |
--name=${name} ` | |
--restart=unless-stopped ` | |
--env-file=.env.devenv ` | |
-v ${pwd}:/devenv ` | |
-p ${port}:8888 ` | |
${name}:${version} | |
# keep window open | |
Read-Host -Prompt "Press Enter to exit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define environment name | |
name="devenv-test1" | |
# define python version - this should match version set in dockerfile.devenv | |
version="py3.9.7" | |
# define the port for this specific environment | |
port=5000 | |
# build image of development environment | |
docker build -f dockerfile.devenv -t ${name}:${version} . | |
# run container based on built image | |
docker run -d \ | |
--name=${name} \ | |
--restart=unless-stopped \ | |
--env-file=.env.devenv \ | |
-v ${pwd}:/devenv \ | |
-p ${port}:8888 \ | |
${name}:${version} | |
# keep window open | |
read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment