feat: docker and docker-compose support

Introduced a Dockerfile and compose.yml to allow the application to run inside a Docker container. This removes the need for local system-level dependencies and offers a more predictable environment for the app. README.md was updated to include Docker-related instructions and an additional environment variable `DOCKER_DB_FOLDER` was added on top of existing ones for Docker support.
This commit is contained in:
Florian Sylvain
2023-08-13 23:40:12 +02:00
parent 60e25cea2f
commit d91dc256a2
3 changed files with 44 additions and 11 deletions
+17 -11
View File
@@ -10,17 +10,22 @@ Don't forget to setup the [Environment variables](#environment-variables)!
### Use with Docker
TODO (or is it...)
#### Compose
The easiest way to run the project is to use docker-compose.
You still need to set up the environment variables, but you can use the `.env` file for that.
Note that some supplementary variables are required for docker-compose to work, like `DOCKER_DB_FOLDER`.
```bash
docker compose up --build -d
```
### Build and run it yourself
#### Requirements
- The project is developed with Go 1.20.5
#### Build
There are 2 scripts to build the project:
- `super_build.sh`
- `super_build.bat`
@@ -34,12 +39,13 @@ of course required, but not necessarily via the `.env` file.
### Environment variables
| Name | Type | Description | Comment |
|----------------------|--------|---------------------------------------|-------------------------------------------------------------------------------------------------------|
| ENVIRONMENT | string | The environment the API is running in | required, `development` or `production` |
| PORT | int | The port the API will use | required |
| CORS_ALLOWED_ORIGINS | string | The allowed origins for CORS | required, semicolon separated list |
| DB_FILE | string | The path to the sqlite db file | required, can be at the root but name still required (e.g. `./gohcms.db`) ; have to end up with `.db` |
| Name | Type | Description | Comment |
|----------------------|--------|-----------------------------------------|-------------------------------------------------------------------------------------------------------|
| ENVIRONMENT | string | The environment the API is running in | required, `development` or `production` |
| PORT | int | The port the API will use | required |
| CORS_ALLOWED_ORIGINS | string | The allowed origins for CORS | required, semicolon separated list |
| DB_FILE | string | The path to the sqlite db file | required, can be at the root but name still required (e.g. `./gohcms.db`) ; have to end up with `.db` |
| DOCKER_DB_FOLDER | string | The path to the sqlite db file's folder | required with docker, this will basically be the host machine folder that contains the sqlite db file |
## API Usage