Skip to content

Commit

Permalink
Still fixing Docker image creation
Browse files Browse the repository at this point in the history
had to downgrade to node 10 because of node-gyp issues
nodejs/node-gyp#1763
  • Loading branch information
silvae86 committed Apr 11, 2020
1 parent 9876e0d commit 75ca20c
Show file tree
Hide file tree
Showing 8 changed files with 7,395 additions and 5,080 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM ubuntu:18.04 as dependencies_ready
ENV SOURCE_BRANCH "master"
ENV NEO4J_ADDRESS "bolt://neo4j:password@neo4j:7687"

RUN apt-get update -qq
RUN apt-get install -y -qq git curl wget python2.7 python-pip
RUN apt-get install -y -qq git curl wget build-essential

FROM dependencies_ready
COPY . /archgraph
WORKDIR /archgraph
RUN git checkout "$SOURCE_BRANCH"
RUN ./conf/install.sh
ENTRYPOINT [ "./conf/run.sh" ]
108 changes: 44 additions & 64 deletions conf/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,60 @@
ROOT_DIR=$(pwd)
echo "Running at $ROOT_DIR"

ENV_NAME="archgraph"
ARCHGRAPH_ENV="archgraph"
PYTHON27_ENV="nodegyp-python27"

if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname)" == "Darwin" ]; then
# Do something under Mac OS X platform
brew cask install miniconda || brew cask upgrade miniconda
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Do something under GNU/Linux platform
rm -rf Miniconda3-latest-Linux-x86_64.sh
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -p "$HOME/miniconda" || ./Miniconda3-latest-Linux-x86_64.sh -u -b -p "$HOME/miniconda"
rm -rf Miniconda3-latest-Linux-x86_64.sh
if [ $(conda > /dev/null) > /dev/null ]; then
brew cask install miniconda || brew cask upgrade miniconda
else
echo "Miniconda already installed, continuing..."
fi
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ] ; then
if ! [ $(conda > /dev/null) > /dev/null ]; then
# Do something under GNU/Linux platform
rm -rf Miniconda3-latest-Linux-x86_64.sh
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -p "$HOME/miniconda" || ./Miniconda3-latest-Linux-x86_64.sh -u -b -p "$HOME/miniconda"
rm -rf Miniconda3-latest-Linux-x86_64.sh
else
echo "Miniconda already installed, continuing..."
fi
fi


# run conda
if [ "$(uname)" == "Darwin" ]; then
source "$HOME/.bash_profile"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
source "$HOME/.profile"
fi

# make conda binary available in path
export PATH="$HOME/miniconda/bin":$PATH
if [ "$(uname)" == "Darwin" ]; then
# make conda binary available in path
export PATH="$HOME/miniconda/bin":$PATH
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# init conda cli
source "$HOME/miniconda/etc/profile.d/conda.sh"
fi

# init conda
source "$HOME/miniconda3/etc/profile.d/conda.sh"
conda init bash
conda deactivate
conda remove --quiet --name "$ENV_NAME" -y --all
conda create --quiet -y -n "$ENV_NAME" python=3.7 anaconda
conda activate "$ENV_NAME"
conda create --quiet -y -n "$PYTHON27_ENV" python=2.7 anaconda
conda activate "$PYTHON27_ENV"
PYTHON27_PATH=$(which python)
echo "Node-Gyp interpreter Python (2.7) is at: ---> ${PYTHON27_PATH} <---"

# create archgraph env
conda create --quiet -y -n "$ARCHGRAPH_ENV" python=3.7 anaconda
conda activate "$ARCHGRAPH_ENV"

# Get location of python interpreter
echo "Python interpreter is at: ---> $(which python) <---"
PYTHON_PATH=$(which python)
echo "Python interpreter is at: ---> ${PYTHON_PATH} <---"

# install pip
conda install pip -y --all
conda install pip -y --all --quiet
echo "Pip at: ---> $(which pip) <---"
# (optional) install any requirements of your current app in this venv
pip install -r "$ROOT_DIR/requirements.txt"
Expand All @@ -53,48 +69,12 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

#install nodejs and yarn
nvm install v13
nvm use v13
npm install -g yarn
#install nodejs
nvm install v10
nvm use v10

# run yarn install
# install frontend stuff
cd frontend
yarn install
cd -

exit 0


# old script below, before using conda

## clean dependencies
#rm -rf backend/env/bin
#rm -rf backend/env/include
#rm -rf backend/env/lib
#rm -rf backend/env/man
#
#brew install openssl
#brew link openssl --force
#brew uninstall python
#brew install python3 --with-brewed-openssl || brew upgrade python3 --with-brewed-openssl
#
##brew install python3 || brew upgrade python3
#
#brew link python
#
#brew install zlib
#export LDFLAGS="-L/usr/local/opt/zlib/lib"
#export CPPFLAGS="-I/usr/local/opt/zlib/include"
#
## install venv
#python -m venv env ||
## activate venv
#source env/bin/activate
## install pip
#curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
#python get-pip.py
## upgrade pip to latest version
#pip install --upgrade pip
## (optional) install any requirements of your current app in this venv
#pip install -r requirements.txt
npm install -g npm@latest
npm config set python "$PYTHON27_PATH"
npm install
24 changes: 15 additions & 9 deletions conf/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,37 @@ echo "Running at $ROOT_DIR"
# maybe remove this later when conda is working correctly in path
# (this was not working on linux without re-exporting the folder to path?)

source "$HOME/.bash_profile" && source "$HOME/.profile" && source "$HOME/.bashrc"
export PATH="$HOME/miniconda/bin":$PATH
if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# init conda cli
source "$HOME/miniconda3/etc/profile.d/conda.sh"
elif [ "$(uname)" == "Darwin" ]; then
conda init zsh
source "$HOME/.zshrc"
conda init bash
source "$HOME/.bash_profile"
fi

if [[ ! -f "README.md" ]] || [[ ! -f "requirements.txt" ]]; then
echo "This script should be run at the root of the project!"
exit 1
fi

eval "$(conda shell.bash hook)"
conda activate archgraph
echo "Python interpreter is at: ---> $(which python) <---"
echo "Pip is at: ---> $(which pip) <---"

# activate nvm and use node v13
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm use v13
export NVM_DIR="$([[ -z "${XDG_CONFIG_HOME-}" ]] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm use v10

echo "Starting archgraph server at $ROOT_DIR"
cd $ROOT_DIR
cd "$ROOT_DIR"

python "$ROOT_DIR/src/Routes/routes.py" --neo4j="$NEO4J_ADDRESS" &
python "$ROOT_DIR/src/Routes/routes.py" --neo4j="$NEO4J_CONNECTION_STRING" &
SERVER_PID=$!
cd "$ROOT_DIR/frontend" || ( echo "folder missing " && exit 1 )
yarn ng serve &
npm start &
CLIENT_PID=$!
cd "$ROOT_DIR" || ( echo "folder missing " && exit 1 )

Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ services:
dockerfile: Dockerfile
args:
- "SOURCE_BRANCH=master"
- "NEO4J_ADDRESS=bolt://neo4j:password@neo4j:7687"
context: .
environment:
- "NEO4J_CONNECTION_STRING=bolt://neo4j:password@neo4j:7687"
ports:
- published: 4200
target: 4200
Expand Down
Loading

0 comments on commit 75ca20c

Please sign in to comment.