Skip to content

Commit 3d36db0

Browse files
author
Louis T. Getterman IV
committed
Kickoff commit
Geared towards being a base for pulling against in subsequent repositories.
1 parent 9ed183d commit 3d36db0

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

Dockerfile

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# GGCOM - Docker - pyenv v201508040404
2+
# Louis T. Getterman IV (@LTGIV)
3+
# www.GotGetLLC.com | www.opensour.cc/ggcom/docker/pyenv
4+
#
5+
# Example usage:
6+
#
7+
# Build
8+
# $] docker build --tag=python .
9+
#
10+
# Run
11+
# $] docker run python --version
12+
# $] docker run --volume="HOST/PATH/PROJECT:/opt/PROJECT" python "/opt/PROJECT/run.py"
13+
#
14+
# Thanks:
15+
#
16+
# Setting up pyenv in docker
17+
# https://gist.github.com/jprjr/7667947
18+
#
19+
################################################################################
20+
FROM ubuntu:14.04.2
21+
MAINTAINER GotGet, LLC <[email protected]>
22+
23+
ENV DEBIAN_FRONTEND noninteractive
24+
25+
RUN apt-get -y update && apt-get -y install \
26+
apt-transport-https \
27+
curl \
28+
gcc \
29+
git-core \
30+
libbz2-dev \
31+
libreadline-dev \
32+
libsqlite3-dev \
33+
libssl-dev \
34+
make \
35+
zlib1g-dev
36+
37+
RUN adduser --disabled-password --gecos "" python_user
38+
39+
WORKDIR /home/python_user
40+
USER python_user
41+
42+
ENV HOME /home/python_user
43+
ENV PYENV_ROOT $HOME/.pyenv
44+
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
45+
46+
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
47+
48+
ADD pycompiler.bash $HOME/pycompiler.bash
49+
ADD version $HOME/version
50+
RUN bash $HOME/pycompiler.bash $HOME/version
51+
RUN rm -rf $HOME/pycompiler.bash $HOME/version
52+
53+
RUN pyenv rehash
54+
55+
RUN pip install --upgrade pip
56+
57+
ENTRYPOINT ["python"]
58+
################################################################################

pycompiler.bash

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
target=$(cat $1 | tr -d '[[:space:]]') \
4+
rexp='^TARGET\.[0-9][\.0-9]*$' \
5+
pylist=$( pyenv install --list )
6+
7+
echo "----------"
8+
echo "$pylist"
9+
echo "----------"
10+
11+
if [ "${#target}" == 1 ] || [ "$target" == "latest" ] || [ -z "$target" ]; then
12+
case $target in
13+
[2-3]*)
14+
pyrexo="${rexp/TARGET/$target}";;
15+
*)
16+
pyrexo="${rexp/TARGET/[0-9]}";;
17+
esac
18+
19+
if [ -z "$target" ]; then
20+
echo "You can select a specific version by editing the 'version' file that's in your Dockerfile directory."
21+
echo "----------"
22+
fi
23+
24+
pyver=$( echo "$pylist" | sed -e 's/^[[:space:]]*//' | grep --regexp $pyrexo | sort --version-sort | tail -n 1 )
25+
26+
else
27+
pyver=$target
28+
fi
29+
unset target rexp pylist pyrexo
30+
31+
echo "Installing Python $pyver, and setting as global Python interpreter:"
32+
33+
pyenv install $pyver
34+
pyenv global $pyver
35+
36+
unset pyver

version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latest

0 commit comments

Comments
 (0)