mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
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:
+15
@@ -0,0 +1,15 @@
|
|||||||
|
FROM golang:1.20.5-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
COPY adapters ./adapters
|
||||||
|
COPY api ./api
|
||||||
|
COPY domain ./domain
|
||||||
|
COPY main ./main
|
||||||
|
COPY useCases ./useCases
|
||||||
|
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -o startServer ./main
|
||||||
|
|
||||||
|
CMD ["./startServer"]
|
||||||
@@ -10,17 +10,22 @@ Don't forget to setup the [Environment variables](#environment-variables)!
|
|||||||
|
|
||||||
### Use with Docker
|
### 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
|
### Build and run it yourself
|
||||||
|
|
||||||
#### Requirements
|
|
||||||
|
|
||||||
- The project is developed with Go 1.20.5
|
|
||||||
|
|
||||||
#### Build
|
#### Build
|
||||||
|
|
||||||
There are 2 scripts to build the project:
|
There are 2 scripts to build the project:
|
||||||
|
|
||||||
- `super_build.sh`
|
- `super_build.sh`
|
||||||
- `super_build.bat`
|
- `super_build.bat`
|
||||||
|
|
||||||
@@ -34,12 +39,13 @@ of course required, but not necessarily via the `.env` file.
|
|||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
| Name | Type | Description | Comment |
|
| Name | Type | Description | Comment |
|
||||||
|----------------------|--------|---------------------------------------|-------------------------------------------------------------------------------------------------------|
|
|----------------------|--------|-----------------------------------------|-------------------------------------------------------------------------------------------------------|
|
||||||
| ENVIRONMENT | string | The environment the API is running in | required, `development` or `production` |
|
| ENVIRONMENT | string | The environment the API is running in | required, `development` or `production` |
|
||||||
| PORT | int | The port the API will use | required |
|
| PORT | int | The port the API will use | required |
|
||||||
| CORS_ALLOWED_ORIGINS | string | The allowed origins for CORS | required, semicolon separated list |
|
| 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` |
|
| 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
|
## API Usage
|
||||||
|
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
services:
|
||||||
|
api:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "${PORT}:8080"
|
||||||
|
volumes:
|
||||||
|
- ${DOCKER_DB_FOLDER}:/app/db/
|
||||||
|
environment:
|
||||||
|
- ENVIRONMENT=${ENVIRONMENT}
|
||||||
|
- PORT=8080
|
||||||
|
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS}
|
||||||
|
- DB_FILE=/app/db/gohcms.db
|
||||||
Reference in New Issue
Block a user