Deploy locally
Deploying the code locally from your computer can be useful to test some features and making sure all the bugs are fixed before pushing your changes to the Github repository.
Preliminary steps
- Create a GitHub account
-
Install Docker Desktop
- Once your done with the steps above, you will need to clone locally the GitHub repository (documentation).
git clone https://github.com/Paleoclim-CNRS/netcdf_editor_app.git
or
git clone git@github.com:Paleoclim-CNRS/netcdf_editor_app.git
Use SSH as a more secure option and HTTPS for basic password-based Git usage. You can find more information here.
If you plan to go for ssh, copy your ssh key to github first (follow this documentation).
At this step, you should have a copy of the Netcdf Editor Application on you local computer.
-
Move in the repository
cd netcdf-editor-app
-
Make sure your repository is ready
Fetch latest changes:
git fetch
If you have done any modification in the repository, you can undo it by using (restore the state of the local repository to match the state of the remote branch):
git reset --hard @{u}
Single Page Web App
- Change into the Single Page directory:
cd Single_Page_WebApp
- Build the image:
docker build -f single_page_webapp.Dockerfile -t netcdf_editor_single_page . --no-cache
The
--no-cache
means everything gets rebuilt - Start the container:
docker run -d -p 8080:8080 netcdf_editor_single_page
-d
means detached mode so once the containers all start the command line is returned to you-p
is for port selectionThe first 8080 is the port on the local machine you can change this to whatever you want.
The second 8080 is the entry port for the application. If you change it, modify the dockerfileSingle_Page_WebApp/single_page_webapp.Dockerfile
underENTRYPOINT
option--port
as well.
- Connect to the container via
http://localhost:8080
(the 8080 refering to the first 8080 in command above)
Multi Page Web App
- Make sure nothing is running:
docker-compose -f docker-compose.yaml --env-file ./config/.env.prod down
- Delete the docker volume (If there has been a database upgrade)
- List volumes:
docker volume ls
- Remove associated volume:
docker volume rm netcdf_editor_app_instance_storage
or remove all volumes of stopped containers:
docker volume prune
- List volumes:
You can deploy the application in 2 different ways:
- PRODUCTION mode
Designed for development. It uses images sent to DockerHub to deploy the containers. Modifications of you local code won't be visible on the deployed application.
- Run
docker-compose -f docker-compose.yaml --env-file ./config/.env.prod up --build -d --scale python_worker=2
- Connect to the application via
http://localhost:43829
(the port is defined inconfig/.env.prod
underNGINX_PORT
)
- Run
- DEVELOPMENT mode
If you want to know more about this, check Use development containers section from Under the Hood documentation.
- If this is the first time running the database then you will need to initialize it with the following commands
- Get command line access to the flask container:
docker exec -it netcdf_editor_app-flask_app-1 /bin/bash
initialize database:
python -m flask init-db
- or use the one liner command:
docker exec -it netcdf_editor_app_flask_app_1 python -m flask init-db
If you don’t do this you might get a
sqlite3.OperationalError
error when running the application - Get command line access to the flask container:
- Run:
docker-compose -f docker-compose.dev.yaml --env-file ./config/.env.dev up --build -d --scale python_worker=2
- Connect to the application via
http://localhost:5000
(the port is defined inconfig/.env.dev
underNGINX_PORT
)