Skip to content

Instantly share code, notes, and snippets.

@Majramos
Last active December 5, 2021 18:04
Show Gist options
  • Save Majramos/dd68948c82ae66f6556541111a9b5fe8 to your computer and use it in GitHub Desktop.
Save Majramos/dd68948c82ae66f6556541111a9b5fe8 to your computer and use it in GitHub Desktop.
Setup a python development environment in docker
local_pg={"host":"localhost","port": 5432,"database":"local_pg","user":"local_pg","password":"local_pg"}
# 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='' '
pandas
numpy
jupyterlab
# 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"
# 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