Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #176

Merged
merged 9 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Build
run: npm ci && npm run docz:build
uses: actions/setup-node@v4
with:
node-version: '10.x'
- run: npm ci
- run: npm run docz:build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sudo apt-get install -y nodejs

For other distro look [here](https://github.com/nodesource/distributions/blob/master/README.md)
or [here](https://nodejs.org/en/download/) for non linux distro.
To make sure everything works fine, your version of nodejs must be >= 10, and your version of npm must be >= 6.
To make sure everything works fine, your version of Node.js must be >= 10, and your version of npm must be >= 6.
To test it:

```shell
Expand Down Expand Up @@ -198,17 +198,17 @@ To use local builds for development or debugging purposes:

## Technical documentation

### view
### View

https://romi.github.io/plant-3d-explorer/

### contribute
### Contribute

The documentation of this package is done by [docz](https://www.docz.site/).
The documentation of this package is done by [docz](https://docz-v1.surge.sh/).
To install it, and its dependencies, do:

```bash
npm install docz react react-dom
npm install docz@1.3.2 docz-theme-default
```

Then:
Expand All @@ -217,4 +217,10 @@ Then:
npm run docz:dev
```

If you experience any difficulty with `docz`, head over [here](https://www.docz.site/docs/getting-started).
To build it within a container:
```shell
./docker/run.sh -v $(pwd)/.docz:/app/.docz \
-c "umask 0002 && npm install [email protected] docz-theme-default && npm run docz:build"
```

If you experience any difficulty with `docz`, head over [here](https://docz-v1.surge.sh/).
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reworked original image based on https://mherman.org/blog/dockerizing-a-react-app/#docker
FROM node:12
FROM node:10
LABEL maintainer="Jonathan LEGRAND <[email protected]>"

ARG API_URL='https://db.romi-project.eu'
Expand All @@ -14,8 +14,8 @@ WORKDIR /app
COPY package.json ./
COPY package-lock.json ./

#RUN npm ci --only=production
RUN npm install
RUN npm ci --only=production
#RUN npm install
RUN npm install [email protected] -g

COPY . ./
Expand Down
58 changes: 38 additions & 20 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ usage() {
echo "DESCRIPTION:"
echo " Run 'roboticsmicrofarms/plant-3d-explorer' container
By default, start the container with the shared online database by ROMI:
$api_url
${api_url}
"

echo "OPTIONS:"
echo " -t, --tag
Docker image tag to use, default to '$vtag'."
Docker image tag to use, default to '${vtag}'."
echo " --api_url
REACT API URL to use to retrieve dataset, default is '$api_url'.
REACT API URL to use to retrieve dataset, default is '${api_url}'.
Set it to '127.0.0.0:5000' if you have a local plantdb instance running."
echo " -c, --cmd
Defines the command to run at container startup.
By default it starts the Plant 3D Explorer listening to the given API URL."
echo " -p, --port
Port to expose, default is '$port'."
Port to expose, default is '${port}'."
echo " -v, --volume
Volume mapping between host and container to mount a local directory in the container." \
"Absolute paths are required and multiple use of this option is allowed." \
"For example '-v /host/dir:/container/dir' makes the '/host/dir' directory accessible under '/container/dir' within the container."
echo " -h, --help
Output a usage message and exit."
}
Expand All @@ -49,6 +53,14 @@ while [ "$1" != "" ]; do
shift
port=$1
;;
-v | --volume)
shift
if [ "${mount_option}" == "" ]; then
mount_option="-v $1"
else
mount_option="${mount_option} -v $1" # append
fi
;;
-h | --help)
usage
exit
Expand All @@ -61,26 +73,32 @@ while [ "$1" != "" ]; do
shift
done

# Check if we have a TTY or not
if [ -t 1 ]; then
USE_TTY="-t"
else
USE_TTY=""
fi

# Docker commands based on : https://mherman.org/blog/dockerizing-a-react-app/#docker
if [ "$cmd" = "" ]; then
# Start in interactive mode:
docker run \
-it \
--rm \
-p $port:$port \
-e CHOKIDAR_USEPOLLING="true" \
-e REACT_APP_API_URL="$api_url" \
roboticsmicrofarms/plant-3d-explorer:$vtag
if [ "${cmd}" = "" ]; then
# Start in interactive mode, using the `-i` flag (load `~/.bashrc`).
docker run --rm ${mount_option} \
--env CHOKIDAR_USEPOLLING="true" \
--env REACT_APP_API_URL="${api_url}" \
-p ${port}:${port} \
-i ${USE_TTY} \
roboticsmicrofarms/plant-3d-explorer:${vtag}
# --rm : Remove container after closing
# -v ${PWD}:/app : Mount the app folder
# -v /app/node_modules : Mount the node modules
# -e CHOKIDAR_USEPOLLING="true" : Allow hot-reload
else
# Start in non-interactive mode (run the command):
docker run \
--rm \
--env REACT_APP_API_URL="$api_url" \
-p $port:$port \
roboticsmicrofarms/plant-3d-explorer:$vtag \
bash -c "$cmd"
# Start in interactive mode, using the `-i` flag (load `~/.bashrc`).
docker run --rm ${mount_option} \
--env REACT_APP_API_URL="${api_url}" \
-p ${port}:${port} \
-i ${USE_TTY} \
roboticsmicrofarms/plant-3d-explorer:${vtag} \
bash -c "${cmd}"
fi
2 changes: 1 addition & 1 deletion doczrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
ignore: ['README.md'],
title: 'ROMI 3D Plant Visualizer',
title: 'ROMI Plant 3D Explorer',
base: '/plant-3d-explorer/',
hashRouter: true,
menu: [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "sony_visualiseur-plantes-3d",
"name": "plant-3d-explorer",
"version": "0.1.0",
"private": true,
"homepage": "https://db.romi-project.eu/viz/",
Expand Down
Loading
Loading