Skip to content

Running in Docker

skitsanos edited this page Aug 21, 2022 · 3 revisions

In Foxx-builder v.2.x, we added the docker-compose.yml file and a few shortcuts into package.json that will help you to develop your APIs and run them in docker.

docker-compose.yml:

version: "3.9"
services:
  arangodb:
    restart: always
    container_name: "arangodb-dev"
    image: "arangodb/arangodb:latest"
    ports:
      - "8529:8529"
    environment:
      - ARANGO_ROOT_PASSWORD=openSesame
    volumes:
      - .backup:/backup

You can use npm or yarn to run things; just keep in mind that there is an order of actions to consider.

The flow would be like this:

  1. Start docker container:
yarn run docker:start

o, manually:

docker compose -p foxx-backend -f docker-compose.yml up -d
  1. Setup the development database:
yarn run docker:setup-db

or, manually:

docker exec -it arangodb-dev arangosh --server.username root --server.password openSesame --javascript.execute-string "db._createDatabase('dev',{},[{username: 'dev', passwd: 'sandbox', active: true}]);"
  1. Register development database server with Foxx CLI yarn run register-foxx-dev-server or
foxx server set dev http://dev:sandbox@localhost:8529
  1. Install Foxx Microservices on /api endpoint on development database
yarn run install-foxx-dev

or, manually:

foxx install /api . --server dev --database dev

After microservices are installed, during the development, all you will need to call is a replace method - yarn run replace-foxx-dev

Docker Data Backup and Restore

To backup your ArangoDb data locally, just run the following:

docker exec -it arangodb-dev arangodump --overwrite true --server.database dev --server.username root --server.password openSesame --output-directory /backup

It will backup data into /backup folder that you mounted as a volume in your docker-compose.yml to .backup. For more examples of arangodump utility, please refer to https://www.arangodb.com/docs/stable/programs-arangodump-examples.html

Restoring from the backup is done in the following way:

docker exec -it arangodb-dev arangorestore --server.database dev --server.username root --server.password openSesame --input-directory /backup

Underneath it is using arangorestore utility, you can see more examples of how to use it at https://www.arangodb.com/docs/stable/programs-arangorestore-examples.html

Clone this wiki locally