-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mudando de requirements txt para poetry
- Loading branch information
Samuel Ferino
committed
Apr 11, 2024
1 parent
a231d26
commit aa65a38
Showing
16 changed files
with
164 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
# PyCharm | ||
.idea/ | ||
|
||
poetry.lock | ||
|
||
.env | ||
|
||
# Python specific | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
* | ||
!api.py | ||
!requirements.txt | ||
!api | ||
!config.py | ||
!main.py | ||
!pyproject.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.7.4 | ||
3.10.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
FROM python:3.7.4-alpine | ||
FROM python:3.9-alpine AS builder | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY requirements.txt . | ||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
COPY pyproject.toml ./ | ||
RUN pip install poetry==1.1.12 | ||
|
||
COPY ./api.py . | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install --no-dev --no-interaction --no-ansi | ||
|
||
|
||
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 | ||
COPY main.py . | ||
COPY config.py . | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["gunicorn", "-b", "0.0.0.0:8000", "--log-level", "debug", "api:app"] | ||
CMD ["gunicorn", "-b", "0.0.0.0:8000", "--log-level", "debug", "main:app"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import logging | ||
import logging.handlers | ||
from logstash_formatter import LogstashFormatterV1 | ||
|
||
from config import LOGSTASH_HOST, LOGSTASH_PORT | ||
|
||
logstash_handler = logging.handlers.SocketHandler(LOGSTASH_HOST, LOGSTASH_PORT) | ||
logstash_handler.setFormatter(LogstashFormatterV1()) | ||
logger = logging.getLogger() | ||
logger.addHandler(logstash_handler) | ||
logger.setLevel(logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LOGSTASH_HOST='localhost' | ||
LOGSTASH_PORT=5000 | ||
LOGGING_FORMAT='%(asctime)s - %(name)s - %(levelname)s - %(message)s' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tool.poetry] | ||
name = "app" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Samuel Ferino <sferino@lenovo.com>"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
click = "7.1.2" | ||
Flask = "1.1.2" | ||
gunicorn = "20.0.4" | ||
itsdangerous = "1.1.0" | ||
Jinja2 = "2.11.2" | ||
MarkupSafe = "1.1.1" | ||
Werkzeug = "1.0.1" | ||
logstash_formatter = "0.5.17" | ||
|
||
[tool.poetry.dev-dependencies] | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ itsdangerous==1.1.0 | |
Jinja2==2.11.2 | ||
MarkupSafe==1.1.1 | ||
Werkzeug==1.0.1 | ||
logstash_formatter==0.5.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# include .env | ||
|
||
all: run | ||
.PHONY: all build run clean | ||
|
||
build: clean | ||
@echo | ||
@echo "******************** BUILDING & TAGGING DOCKER IMAGE **********************************" | ||
docker compose up -d --build | ||
@echo | ||
@echo | ||
docker ps | ||
@echo | ||
|
||
|
||
run: | ||
@echo | ||
@echo "******************** RUNNING DOCKER INSTANCE **********************************" | ||
docker compose up -d | ||
@echo | ||
@echo | ||
docker ps | ||
@echo | ||
|
||
|
||
clean: | ||
@echo | ||
@echo "******************** KILLING CONTAINER **********************************" | ||
docker compose down --volumes | ||
@echo | ||
docker ps | ||
@echo |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: '3.8' | ||
|
||
services: | ||
elasticsearch: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 | ||
environment: | ||
- node.name=elasticsearch | ||
- discovery.type=single-node | ||
ports: | ||
- "9200:9200" | ||
volumes: | ||
- elasticsearch_data:/usr/share/elasticsearch/data | ||
restart: always | ||
|
||
kibana: | ||
image: docker.elastic.co/kibana/kibana:7.17.0 | ||
environment: | ||
ELASTICSEARCH_URL: http://elasticsearch:9200 | ||
ports: | ||
- "5601:5601" | ||
depends_on: | ||
- elasticsearch | ||
restart: always | ||
|
||
logstash: | ||
image: docker.elastic.co/logstash/logstash:7.17.0 | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- ./logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf | ||
environment: | ||
LS_JAVA_OPTS: "-Xmx256m -Xms256m" | ||
restart: always | ||
|
||
volumes: | ||
elasticsearch_data: | ||
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
input { | ||
tcp { | ||
port => 5000 | ||
codec => json | ||
} | ||
} | ||
|
||
output { | ||
elasticsearch { | ||
hosts => ["elasticsearch:9200"] | ||
# index => "comments" | ||
} | ||
stdout { codec => rubydebug } | ||
} |