Skip to content

Commit

Permalink
Merge branch 'dev' into feature/OPT-793
Browse files Browse the repository at this point in the history
  • Loading branch information
PacoCid authored Mar 30, 2023
2 parents ed8d05e + 803d2ea commit eb496cf
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
4 changes: 3 additions & 1 deletion deployment/Dockerfile.application
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ COPY . .

RUN pip install .

RUN rm -r ../app/*

# Remove git and geos-dev dependencies
RUN apk del git geos-dev

ENTRYPOINT ["uvicorn", "startleft.startleft.api.fastapi_server:webapp", "--host", "0.0.0.0", "--port", "5000"]
ENTRYPOINT ["startleft", "server", "--host", "0.0.0.0"]
8 changes: 8 additions & 0 deletions deployment/Dockerfile.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM squidfunk/mkdocs-material

RUN pip install --upgrade pip

RUN pip install mkdocs-glightbox

COPY /docs ./docs
COPY mkdocs.yml .
5 changes: 0 additions & 5 deletions deployment/Dockerfile.documentation

This file was deleted.

6 changes: 3 additions & 3 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
services:
docs:
startleft-docs:
build:
context: ..
dockerfile: deployment/Dockerfile.documentation
dockerfile: deployment/Dockerfile.docs
ports:
- 8000:8000
container_name: startleft-docs

application:
startleft-app:
build:
context: ..
dockerfile: deployment/Dockerfile.application
Expand Down
15 changes: 5 additions & 10 deletions docs/integration/Quickstart-Guide-for-Integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ git checkout release/1.5.0

Now, we can create the StartLeft image:
```shell
docker build . -f deployment/Dockerfile.application -t startleft
docker build . -f deployment/Dockerfile.docs.application.application -t startleft
```

And, finally, we can run the docker container for the image we have just generated. Notice that you can select the
Expand Down Expand Up @@ -100,17 +100,12 @@ For more details about how to use the StartLeft API, you can check the [REST API
The Dockerfile provided should be enough for the most common integration scenarios, but, of course, it is possible to
create a custom docker image for StartLeft. For that, you can take the existent
[Dockerfile](https://raw.githubusercontent.com/iriusrisk/startleft/main/Dockerfile) available in the root of the StartLeft
repository as a base. However, you must bear in mind the following considerations:
repository as a base. However, you must bear in mind that every [official python image from the Docker Hub](https://hub.docker.com/_/python)
for versions over 3.6 should work, but:

* Every [official python image from the Docker Hub](https://hub.docker.com/_/python) for versions over 3.6 should work, but:
* Depending on the base image, you may need to install additional libraries.
* **Debian/Ubuntu based python official images present security vulnerabilities**. This is the reason we decided
* Depending on the base image, you may need to install additional libraries.
* **Debian/Ubuntu based python official images present security vulnerabilities**. This is the reason we decided
to use the Alpine based one despite the fact it is significantly slower than others at building time.
* Although you could set as the entrypoint the `startleft server` command, it is more recommendable to just use the uvicorn
command, that also allows you to select the default deployment port:
```
ENTRYPOINT ["uvicorn", "startleft.startleft.api.fastapi_server:webapp", "--host", "0.0.0.0", "--port", "5000"]
```

## In batch processes

Expand Down
4 changes: 2 additions & 2 deletions startleft/startleft/api/fastapi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def load_custom_openapi():
return None


def run_webapp(port: int):
uvicorn.run(webapp, host="127.0.0.1", port=port, log_config=get_log_config())
def run_webapp(host: str, port: int):
uvicorn.run(webapp, host=host, port=port, log_config=get_log_config())


@webapp.exception_handler(HTTPException)
Expand Down
5 changes: 3 additions & 2 deletions startleft/startleft/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,16 @@ def search(iac_type, query, source_file):


@cli.command()
@click.option('--host', '-h', default="127.0.0.1", envvar='STARTLEFT_HOST', help='Startleft deployment host.')
@click.option('--port', '-p', default=5000, envvar='STARTLEFT_PORT', help='Startleft deployment port.')
def server(port: int):
def server(host: str, port: int):
"""
Launches the REST server to generate OTMs from requests
"""
configure_logging(verbose=True)
logger.info(f'Startleft version: {version}')

fastapi_server.run_webapp(port)
fastapi_server.run_webapp(host, port)


if __name__ == '__main__':
Expand Down

0 comments on commit eb496cf

Please sign in to comment.