Skip to content

Commit

Permalink
API: add gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Licari committed Nov 28, 2023
1 parent d6bb8ae commit ff1d236
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: api
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: app
push: true
Expand Down
5 changes: 3 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ RUN pip3 install -r requirements.txt

COPY . .

EXPOSE 5000
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0", "--port", "5000"]
EXPOSE 8000

CMD ["gunicorn", "-b", "0.0.0.0", 'api:create_app()']
3 changes: 2 additions & 1 deletion api/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def create_app():
app = Flask(__name__)
app.config.from_object('api.settings')
apiv1 = Blueprint("version1", "version1")
cors = CORS(app, resources={r"/api/v1/*": {"origins": app.config['CORS_ALLOWED_ORIGINS']}})
# Apply CORS
CORS(app, resources={r"/api/v1/*": {"origins": app.config['CORS_ALLOWED_ORIGINS']}})

w3 = Web3(Web3.HTTPProvider(app.config['FAUCET_RPC_URL']))
w3.middleware_onion.add(construct_sign_and_send_raw_middleware(app.config['FAUCET_PRIVATE_KEY']))
Expand Down
3 changes: 2 additions & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ cachetools==5.3.2
python-dotenv==1.0.0
web3==6.11.3
pytest==7.4.3
pytest-mock==3.12.0
pytest-mock==3.12.0
gunicorn==21.2.0

0 comments on commit ff1d236

Please sign in to comment.