refresh
This commit is contained in:
parent
899cb05c1b
commit
ab1e426a17
85
Dockerfile
85
Dockerfile
|
@ -1,83 +1,12 @@
|
||||||
# Python builder stage
|
FROM python:alpine3.18
|
||||||
FROM python:alpine3.18 AS py-builder
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
# Copy only the pyproject.toml files
|
RUN apk update && apk add --no-cache git gcc curl postgresql-client
|
||||||
COPY core/pyproject.toml /app/core/
|
RUN curl -sSL https://install.python-poetry.org | python
|
||||||
COPY chat/pyproject.toml /app/chat/
|
ENV PATH="${PATH}:/root/.local/bin"
|
||||||
COPY notifier/pyproject.toml /app/notifier/
|
RUN poetry config virtualenvs.create false && poetry install --no-dev
|
||||||
|
|
||||||
# Install system dependencies
|
|
||||||
RUN apk update && apk add --no-cache \
|
|
||||||
gcc \
|
|
||||||
curl \
|
|
||||||
git
|
|
||||||
|
|
||||||
# Install Poetry
|
|
||||||
RUN curl -sSL https://install.python-poetry.org | python -
|
|
||||||
|
|
||||||
# Configure environment variables and install Python dependencies
|
|
||||||
RUN echo "export PATH=$PATH:/root/.local/bin" >> ~/.bashrc && \
|
|
||||||
. ~/.bashrc && \
|
|
||||||
poetry config virtualenvs.create false && \
|
|
||||||
poetry install --no-dev
|
|
||||||
|
|
||||||
# Go builder stage
|
|
||||||
FROM golang:1.21.3-alpine3.18 AS go-builder
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /authorizer
|
|
||||||
|
|
||||||
# Copy the entire submodule directory
|
|
||||||
COPY authorizer /authorizer
|
|
||||||
|
|
||||||
# Fetch submodules
|
|
||||||
RUN apk update && apk add --no-cache git && \
|
|
||||||
git submodule update --init --recursive
|
|
||||||
|
|
||||||
ARG VERSION="latest"
|
|
||||||
ENV VERSION="$VERSION"
|
|
||||||
|
|
||||||
# Build the server
|
|
||||||
RUN cd /authorizer && \
|
|
||||||
make clean && make && \
|
|
||||||
chmod 777 build/server
|
|
||||||
|
|
||||||
# Final image
|
|
||||||
FROM alpine:3.18
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy built services from previous stages
|
|
||||||
COPY --from=go-builder /authorizer /app/authorizer
|
|
||||||
|
|
||||||
# Copy Python dependencies from the py-builder stage
|
|
||||||
COPY --from=py-builder /root/.local /root/.local
|
|
||||||
|
|
||||||
# Install system dependencies
|
|
||||||
RUN apk update && apk add --no-cache \
|
|
||||||
gcc \
|
|
||||||
curl \
|
|
||||||
git \
|
|
||||||
postgresql \
|
|
||||||
supervisor \
|
|
||||||
make \
|
|
||||||
python3 \
|
|
||||||
py3-pip
|
|
||||||
|
|
||||||
# Install Python dependencies for gateway project
|
|
||||||
COPY . /app/
|
|
||||||
RUN poetry config virtualenvs.create false && \
|
|
||||||
poetry install --no-dev
|
|
||||||
|
|
||||||
# Supervisor configuration
|
|
||||||
COPY supervisor/conf.d/* /etc/supervisor/conf.d/
|
|
||||||
|
|
||||||
# Expose ports for each service
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Command to start Supervisor
|
CMD ["python", "server.py"]
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
|
||||||
|
|
5
main.py
5
main.py
|
@ -4,8 +4,6 @@ from os.path import exists
|
||||||
|
|
||||||
from ariadne import load_schema_from_path, make_executable_schema
|
from ariadne import load_schema_from_path, make_executable_schema
|
||||||
from ariadne.asgi import GraphQL
|
from ariadne.asgi import GraphQL
|
||||||
from granian import Granian
|
|
||||||
from granian.server import Interfaces
|
|
||||||
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
||||||
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
||||||
from sentry_sdk.integrations.redis import RedisIntegration
|
from sentry_sdk.integrations.redis import RedisIntegration
|
||||||
|
@ -57,6 +55,3 @@ async def shutdown():
|
||||||
|
|
||||||
app = Starlette(debug=True, on_startup=[start_up], on_shutdown=[shutdown])
|
app = Starlette(debug=True, on_startup=[start_up], on_shutdown=[shutdown])
|
||||||
app.mount('/', GraphQL(schema, debug=True))
|
app.mount('/', GraphQL(schema, debug=True))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
Granian(target='main:app', port=8888, interface=Interfaces.ASGI, reload=True).serve()
|
|
||||||
|
|
19
server.py
Normal file
19
server.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from granian.constants import Interfaces
|
||||||
|
from granian.server import Granian
|
||||||
|
|
||||||
|
from settings import PORT
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print('[server] starting...')
|
||||||
|
|
||||||
|
granian_instance = Granian(
|
||||||
|
'main:app',
|
||||||
|
address='0.0.0.0', # noqa S104
|
||||||
|
port=PORT,
|
||||||
|
threads=2,
|
||||||
|
websockets=False,
|
||||||
|
interface=Interfaces.ASGI,
|
||||||
|
reload=True
|
||||||
|
)
|
||||||
|
granian_instance.serve()
|
|
@ -1,7 +1,7 @@
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
|
|
||||||
PORT = 80
|
PORT = 8000
|
||||||
REDIS_URL = environ.get('REDIS_URL') or 'redis://127.0.0.1'
|
REDIS_URL = environ.get('REDIS_URL') or 'redis://127.0.0.1'
|
||||||
API_BASE = environ.get('API_BASE') or 'https://core.discours.io/'
|
API_BASE = environ.get('API_BASE') or 'https://core.discours.io/'
|
||||||
AUTH_URL = environ.get('AUTH_URL') or 'https://auth.discours.io/'
|
AUTH_URL = environ.get('AUTH_URL') or 'https://auth.discours.io/'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user