|
| 1 | +# Structr Docker Setup |
| 2 | + |
1 | 3 | [](https://github.com/structr/docker-setup/actions/workflows/main.yml) |
2 | 4 |
|
3 | | -# Structr Docker Setup |
| 5 | +A Docker Compose setup for running Structr with a pre-configured Neo4j database. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +- Docker |
| 12 | +- Docker Compose |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Quick Start (Easiest Method) |
| 17 | + |
| 18 | +This is the simplest way to get started. No configuration needed. |
| 19 | + |
| 20 | +1. **Start the containers:** |
| 21 | + ```bash |
| 22 | + docker compose up -d |
| 23 | + ``` |
| 24 | + |
| 25 | +2. **Access Structr:** |
| 26 | + Open http://127.0.0.1:8082/structr/ in your browser |
| 27 | + |
| 28 | +3. **Stop the containers:** |
| 29 | + ```bash |
| 30 | + docker compose down |
| 31 | + ``` |
| 32 | + |
| 33 | +**Note:** This uses Docker-managed volumes. Your data persists between restarts but is managed internally by Docker. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Advanced Setup (Custom Volume Directories) |
| 38 | + |
| 39 | +If you want to access Structr data directly on your host filesystem (useful for deployments and backups), you can use custom volume mounts. |
| 40 | + |
| 41 | +### Initial Setup |
| 42 | + |
| 43 | +1. **Run the setup script:** |
| 44 | + ```bash |
| 45 | + ./setup.sh |
| 46 | + ``` |
| 47 | + This creates local directories and sets proper permissions. |
| 48 | + |
| 49 | +2. **Add your license file:** |
| 50 | + - If you have a Structr license, copy it to `./structr/license.key` |
| 51 | + - For community edition, the setup script creates an empty file for you |
| 52 | + |
| 53 | +3. **Modify docker-compose.yml:** |
| 54 | + |
| 55 | + Replace the named volumes with bind mounts. Change the `volumes` section for each service: |
| 56 | + |
| 57 | + **For Neo4j:** |
| 58 | + ```yaml |
| 59 | + volumes: |
| 60 | + - ./volumes/neo4j-database:/data |
| 61 | + - ./volumes/neo4j-logs:/logs |
| 62 | + ``` |
| 63 | +
|
| 64 | + **For Structr:** |
| 65 | + ```yaml |
| 66 | + volumes: |
| 67 | + - ./volumes/structr-files:/var/lib/structr/files |
| 68 | + - ./volumes/structr-repository:/var/lib/structr/repository |
| 69 | + - ./volumes/structr-logs:/var/lib/structr/logs |
| 70 | + - ./structr/license.key:/var/lib/structr/license.key |
| 71 | + ``` |
| 72 | +
|
| 73 | +4. **Start the containers:** |
| 74 | + ```bash |
| 75 | + docker compose up -d |
| 76 | + ``` |
| 77 | + |
| 78 | +### Benefits of Custom Volume Directories |
| 79 | + |
| 80 | +- Direct access to logs in `./volumes/structr-logs/` and `./volumes/neo4j-logs/` |
| 81 | +- Easy backup and restore of data |
| 82 | +- Simplified deployment workflows (see below) |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Working with Containers |
| 87 | + |
| 88 | +### View running containers |
| 89 | +```bash |
| 90 | +docker ps |
| 91 | +``` |
| 92 | + |
| 93 | +### Access container shell |
| 94 | +```bash |
| 95 | +docker exec -it <container_id> /bin/sh |
| 96 | +``` |
4 | 97 |
|
5 | | -### Requirements: |
6 | | -- docker |
7 | | -- (docker-compose) |
| 98 | +### View logs |
| 99 | +```bash |
| 100 | +docker compose logs # All logs |
| 101 | +docker compose logs structr # Structr logs only |
| 102 | +docker compose logs neo4j # Neo4j logs only |
| 103 | +``` |
8 | 104 |
|
9 | | ----- |
| 105 | +--- |
10 | 106 |
|
11 | | -### First steps: |
| 107 | +## Deployment Workflow |
12 | 108 |
|
| 109 | +When using custom volume directories, you can deploy Structr applications through the repository directory. |
13 | 110 |
|
14 | | -- Make sure, you have a valid Structr license.key file and copy it to ./structr/license.key. If you want to run the community edition of Structr, you can create an empty file and move it also to ./structr/license.key. |
| 111 | +**Important: Follow this order:** |
15 | 112 |
|
16 | | -### Usage with docker-compose: |
17 | | -##### Initial setup: |
| 113 | +1. Clone your application repository to `./volumes/structr-repository` |
18 | 114 |
|
19 | | -- Run the setup.sh script before starting the stack, so all necessary volume folders for mounting to the containers are created. (Only for Unix and macOS users) |
20 | | -- Copy your license.key file to ./structr/license.key |
21 | | -- Run `docker-compose build` |
| 115 | +2. Navigate to Structr's dashboard at http://localhost:8082/structr/#dashboard → Deployment |
22 | 116 |
|
23 | | -##### Starting the instances: |
24 | | -- Run `docker-compose --compatibility up -d` to start Neo4j and Structr |
25 | | -- Open `http://127.0.0.1:8082/structr/` in your browser to access Structr |
| 117 | +3. **Import application:** |
| 118 | + - Enter `/var/lib/structr/repository/webapp` in the "Application import from server directory" field |
| 119 | + - Click import |
26 | 120 |
|
27 | | -##### Stopping the instances: |
28 | | -- `docker-compose down` |
| 121 | +4. **Export changes:** |
| 122 | + - After making changes in Structr |
| 123 | + - Enter `/var/lib/structr/repository/webapp` in the "Application export to server directory" field |
| 124 | + - Click export |
29 | 125 |
|
30 | | -##### Inspecting the containers |
31 | | -- `docker ps` |
32 | | -- `note the container id` |
33 | | -- `docker exec -it <Unique identifier for container> /bin/sh` |
| 126 | +5. **Commit and push:** |
| 127 | + - From the host system, commit your changes in `./volumes/structr-repository` |
| 128 | + - Push to your repository |
34 | 129 |
|
35 | | -##### Inpecting the service log files |
36 | | -- `docker-compose logs` will print out the server.log of structr and the neo4j.log of Neo4j |
37 | | -- The Structr container server.log will also be written to ./volumes/structr-logs/server.log, the Neo4j debug.log and neo4j.log will be written to ./volumes/neo4j-logs/*.log |
| 130 | +6. **Deploy updates:** |
| 131 | + - Pull the latest changes |
| 132 | + - Repeat from step 3 |
38 | 133 |
|
39 | | ----- |
| 134 | +--- |
40 | 135 |
|
41 | | -### Usage with docker swarm: |
42 | | -##### Initial setup: |
| 136 | +## Configuration |
43 | 137 |
|
44 | | -- Run the setup.sh script before starting the stack, so all necessary volume folders for mounting to the containers are created. (Only for Unix and macOS users) |
45 | | -- copy your license.key file to ./structr/license.key |
46 | | -- run `docker swarm init` |
| 138 | +### Default Credentials |
47 | 139 |
|
48 | | -##### Starting the instances: |
49 | | -- Run `docker stack deploy --compose-file docker-compose.yml structr` to start Neo4j and Structr |
50 | | -- Open `http://127.0.0.1:8082/structr/` in your browser to access Structr |
| 140 | +- **Structr:** |
| 141 | + - Username: `admin` |
| 142 | + - Password: `admin` |
51 | 143 |
|
52 | | -##### Stopping the instances: |
53 | | -- `docker stack rm structr` |
| 144 | +- **Neo4j:** |
| 145 | + - Username: `neo4j` |
| 146 | + - Password: `structrDockerSetup` |
54 | 147 |
|
55 | | -##### Inspecting the containers |
56 | | -- `docker ps` |
57 | | -- `note the container id` |
58 | | -- `docker exec -it <Unique identifier for container> /bin/sh` |
| 148 | +### Resource Limits |
59 | 149 |
|
60 | | -##### Inspecting the stack |
61 | | -- Run `docker stack ps structr` to get a list of all tasks in the structr stack |
62 | | -- Run `docker stack services structr` to get a list of all services in the structr stack |
| 150 | +You can adjust CPU and memory limits in `docker-compose.yml` under the `deploy.resources` section for each service. |
63 | 151 |
|
64 | | -##### Inpecting the service log files |
65 | | -- The Structr container server.log will be written to ./volumes/structr-logs/server.log, the Neo4j debug.log and neo4j.log will be written to ./volumes/neo4j-logs/*.log |
| 152 | +Default limits: |
| 153 | +- **CPU:** 2 cores limit, 1 core reserved |
| 154 | +- **Memory:** 4GB limit, 1GB reserved |
66 | 155 |
|
67 | | ----- |
| 156 | +--- |
68 | 157 |
|
69 | | -### Customizing Ressources |
70 | | -The CPU and RAM configuration of the containers can be changed in the docker-compose.yml file. |
| 158 | +## Troubleshooting |
71 | 159 |
|
72 | | ----- |
| 160 | +### Containers won't start |
| 161 | +- Check if ports 8082, 7474, 7473, or 7687 are already in use |
| 162 | +- View logs with `docker compose logs` |
73 | 163 |
|
74 | | -### Deployment Roundtrip of an Structr application (order is crucial!!!): |
| 164 | +### Permission issues with custom volumes |
| 165 | +- Run the setup script again: `./setup.sh` |
| 166 | +- Ensure your user is in the `structr` group (may require logout/login) |
75 | 167 |
|
76 | | -1. clone repository to ./volumes/structr-repository |
77 | | -2. goto `http://localhost:8082/structr/#dashboard` -> Deployment |
78 | | -3. copy `/var/lib/structr/repository/webapp` into the 'Application import from server directory' input field and click on the import button |
79 | | -4. when changes have been made copy the same path into the 'Application export to server directory' input field and click the button |
80 | | -5. commit your changes on the host system to github |
81 | | -6. pull the new repository version |
82 | | -7. push your changes |
83 | | -8. repeat from 3. |
| 168 | +### Data persistence |
| 169 | +- **Quick Start method:** Data stored in Docker volumes, persists until you run `docker compose down -v` |
| 170 | +- **Advanced method:** Data stored in `./volumes/` directory on your host |
0 commit comments