Skip to content

Commit

Permalink
adicionando keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Ferino committed Apr 13, 2024
1 parent 740112d commit 69bc429
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
3 changes: 0 additions & 3 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ RUN poetry config virtualenvs.create false \

FROM python:3.9-alpine AS production

# COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /opt/app/.venv /opt/app/.venv

ENV PATH="/opt/app/.venv/bin:$PATH"



WORKDIR /opt/app

COPY api ./api
Expand Down
3 changes: 2 additions & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ Existem outros comandos disponíveis no arquivo `Makefile`: `make buid`, `make r
Caso deseje executar localmente, execute os seguintes comandos em máquina Linux:
```bash
$ pip install -r requirements.txt
$ pip install poetry==1.1.12
$ poetry install --no-dev --no-interaction --no-ansi
$ sudo apt install gunicorn
$ gunicorn --log-level debug api:app
```
Expand Down
6 changes: 3 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def api_comment_new():
@app.route('/api/comment/list/<content_id>')
def api_comment_list(content_id):
content_id = '{}'.format(content_id)
app.logger.info('Trying to retrieve comment')
logger.info('Trying to retrieve comment')


if content_id in comments:
return jsonify(comments[content_id])
else:
app.logger.error('Comment id %s does not exist', content_id)
logger.error('Comment id %s does not exist', content_id)
message = 'content_id {} not found'.format(content_id)
response = {
'status': HTTPStatus.NOT_FOUND,
Expand All @@ -59,4 +59,4 @@ def api_comment_list(content_id):

@app.route('/health')
def api_healthcheck():
return {}, HTTPStatus.OK
return {}, HTTPStatus.OK
7 changes: 4 additions & 3 deletions local_infra/elk/logstash/logstash.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
input {
tcp {
port => 5000
udp {
port => 8000
codec => json
}
}

output {
elasticsearch {
hosts => ["elasticsearch:9200"]
# index => "comments"
index => "comments"
}
stdout { codec => rubydebug }
}

24 changes: 24 additions & 0 deletions local_infra/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM quay.io/keycloak/keycloak:latest as builder

# Enable health and metrics support
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true

# Configure a database vendor
ENV KC_DB=postgres

WORKDIR /opt/keycloak
# for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/

# change these values to point to a running postgres instance
ENV KC_DB=postgres
ENV KC_DB_URL=<DBURL>
ENV KC_DB_USERNAME=<DBUSERNAME>
ENV KC_DB_PASSWORD=<DBPASSWORD>
ENV KC_HOSTNAME=localhost
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
2 changes: 2 additions & 0 deletions local_infra/keycloak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:24.0.2 start-dev

0 comments on commit 69bc429

Please sign in to comment.