Fixed router not working
This commit is contained in:
parent
58d5493584
commit
20a2636677
@ -6,12 +6,16 @@ COPY . .
|
|||||||
|
|
||||||
RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
|
RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
|
||||||
|
|
||||||
|
# Generating routers/commentsRouter.go
|
||||||
|
RUN bee generate routers
|
||||||
|
|
||||||
# Generating the swagger
|
# Generating the swagger
|
||||||
RUN timeout 20 bee run -gendoc=true -downdoc=true -runmode=dev || :
|
RUN timeout 20 bee run -gendoc=true -downdoc=true -runmode=dev || :
|
||||||
|
|
||||||
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
|
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
|
||||||
RUN sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html
|
RUN sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html
|
||||||
|
|
||||||
|
RUN ls -l routers
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
|
||||||
|
|
||||||
|
43
README.md
43
README.md
@ -8,12 +8,30 @@ To install the Beego bee command :
|
|||||||
|
|
||||||
go install github.com/beego/bee/v2@master
|
go install github.com/beego/bee/v2@master
|
||||||
|
|
||||||
To build and run :
|
## Running the app locally
|
||||||
|
In order to run the application we need to correct some errors that beego generates.
|
||||||
|
|
||||||
go mod tidy
|
**Router generation**
|
||||||
bee run -downdoc=true -gendoc=true
|
|
||||||
|
|
||||||
## Full deploy
|
Beego generates the routers from the comment of the controllers methods. However, there seems to be some errors when we let beego generate th routers from `bee run`.
|
||||||
|
|
||||||
|
We need to use `bee generate routers` to have a working router file.
|
||||||
|
|
||||||
|
**Swagger generation**
|
||||||
|
|
||||||
|
Using `bee run -downdoc=true -gendoc=true` beego download a swagger template and generate the JSON file (swagger.json) in `swagger/`. However the swagger template in `swagger/index.html` does not change the exemple's url for our current JSON file. When running locally we have to edit the call to construct the object holding the swagger information, with the parameter url set with the relative path to our JSON swagger file :
|
||||||
|
|
||||||
|
```
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "swagger.json",
|
||||||
|
...
|
||||||
|
...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
This issue is fixed in the Dockerfile build with two `sed` to change the value of the swagger file URL.
|
||||||
|
|
||||||
|
## Deployment with Docker compose
|
||||||
|
|
||||||
Deploy with docker:
|
Deploy with docker:
|
||||||
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml up --build`
|
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml up --build`
|
||||||
@ -23,15 +41,22 @@ and populate DB (or other scripts) with:
|
|||||||
|
|
||||||
or out of docker `./scripts/populate_models.sh ./scripts/demo.json`
|
or out of docker `./scripts/populate_models.sh ./scripts/demo.json`
|
||||||
|
|
||||||
## Dev
|
### Dev
|
||||||
|
|
||||||
Start DB with `docker-compose up -d` and run the API with `bee run -downdoc=true -gendoc=true`
|
- Start DB with `docker-compose up -d`
|
||||||
|
- Run the API with `bee run -downdoc=true -gendoc=true`
|
||||||
|
|
||||||
|
|
||||||
## Multinode
|
### Multinode
|
||||||
|
|
||||||
|
Deploy :
|
||||||
|
|
||||||
Deploy
|
|
||||||
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build`
|
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build`
|
||||||
|
|
||||||
Populate
|
## Populating the MongoDB database
|
||||||
|
|
||||||
|
From the root of the projet run :
|
||||||
|
|
||||||
`./scripts/multinode.sh ./scripts/demo.json`
|
`./scripts/multinode.sh ./scripts/demo.json`
|
||||||
|
|
||||||
|
This script should be updated to be ran from anywhere.
|
@ -2,7 +2,8 @@ version: '3.4'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
oc-catalog:
|
oc-catalog:
|
||||||
image: oc-catalog
|
image: oc-catalog:latest
|
||||||
|
container_name: oc-catalog
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- DOCKER_DCNAME=DC_myDC
|
- DOCKER_DCNAME=DC_myDC
|
||||||
|
@ -125,3 +125,4 @@ func Init() {
|
|||||||
initAuthMiddleware()
|
initAuthMiddleware()
|
||||||
initUglyFixes()
|
initUglyFixes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user