-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Dockerfile to docker dir + add build & run scripts
- Loading branch information
1 parent
bea4805
commit f1ea73a
Showing
4 changed files
with
178 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# Example usages: | ||
############################################################################### | ||
# 1. Default build options will create `roboticsmicrofarms/plantviewer:latest` pointing at ROMI database: | ||
# $ ./build.sh | ||
# | ||
# 2. Build image with 'debug' image tag & another 'plantviewer' branch options: | ||
# $ ./build.sh -t debug -b 'feature/faster_docker' | ||
|
||
user=$USER | ||
vtag="latest" | ||
branch='master' | ||
api_url='https://db.romi-project.eu' | ||
docker_opts="" | ||
|
||
usage() { | ||
echo "USAGE:" | ||
echo " ./build.sh [OPTIONS] | ||
" | ||
|
||
echo "DESCRIPTION:" | ||
echo " Build a docker image named 'roboticsmicrofarms/plantviewer' using Dockerfile in same location. | ||
" | ||
|
||
echo "OPTIONS:" | ||
echo " -t, --tag | ||
Docker image tag to use, default to '$vtag'. | ||
" | ||
echo " -u, --user | ||
User name to create inside docker image, default to '$user'. | ||
" | ||
echo " -b, --branch | ||
Git branch to use for cloning '3d-plantviewer' inside docker image, default to '$branch'. | ||
" | ||
echo " --api_url | ||
REACT API URL to use to retrieve dataset, default is '$api_url'. | ||
" | ||
# Docker options: | ||
echo " --no-cache | ||
Do not use cache when building the image, (re)start from scratch. | ||
" | ||
echo " --pull | ||
Always attempt to pull a newer version of the parent image. | ||
" | ||
# General options: | ||
echo " -h, --help | ||
Output a usage message and exit. | ||
" | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-t | --tag) | ||
shift | ||
vtag=$1 | ||
;; | ||
-u | --user) | ||
shift | ||
user=$1 | ||
;; | ||
-b | --branch) | ||
shift | ||
branch=$1 | ||
;; | ||
--api_url) | ||
shift | ||
api_url=$1 | ||
;; | ||
--no-cache) | ||
shift | ||
docker_opts="$docker_opts --no-cache" | ||
;; | ||
--pull) | ||
shift | ||
docker_opts="$docker_opts --pull" | ||
;; | ||
-h | --help) | ||
usage | ||
exit | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Get the date to estimate docker image build time: | ||
start_time=`date +%s` | ||
|
||
# Start the docker image build: | ||
docker build -t roboticsmicrofarms/plantviewer:$vtag $docker_opts \ | ||
--build-arg USER_NAME=$user \ | ||
--build-arg BRANCH=$branch \ | ||
--build-arg API_URL=$api_url \ | ||
. | ||
|
||
# Print docker image build time: | ||
echo | ||
echo "Build time: $(expr `date +%s` - $start_time)s" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# Example usages: | ||
############################################################################### | ||
# 1. Default run starts an interactive shell: | ||
# $ ./run.sh | ||
|
||
vtag="latest" | ||
api_url='https://db.romi-project.eu' | ||
|
||
usage() { | ||
echo "USAGE:" | ||
echo " ./run.sh [OPTIONS] | ||
" | ||
|
||
echo "DESCRIPTION:" | ||
echo " Run 'roboticsmicrofarms/plantviewer:<vtag>' container with a mounted local (host) database. | ||
" | ||
|
||
echo "OPTIONS:" | ||
echo " -t, --tag | ||
Docker image tag to use, default to '$vtag'. | ||
" | ||
echo " --api_url | ||
REACT API URL to use to retrieve dataset, default is '$api_url'. | ||
" | ||
|
||
echo " -h, --help | ||
Output a usage message and exit. | ||
" | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-t | --tag) | ||
shift | ||
vtag=$1 | ||
;; | ||
--api_url) | ||
shift | ||
api_url=$1 | ||
;; | ||
-h | --help) | ||
usage | ||
exit | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Use 'host database path' & 'docker user' to create a bind mount: | ||
if [ "$api_url" != "" ] | ||
then | ||
docker run \ | ||
--env REACT_APP_API_URL="$api_url" \ | ||
-it roboticsmicrofarms/plantviewer:$vtag | ||
else | ||
docker run \ | ||
-it roboticsmicrofarms/plantviewer:$vtag | ||
fi | ||
|
||
|