84 lines
1.9 KiB
Docker
84 lines
1.9 KiB
Docker
# Python builder stage
|
|
FROM python:alpine3.18 AS py-builder
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy only the pyproject.toml files
|
|
COPY core/pyproject.toml /app/core/
|
|
COPY chat/pyproject.toml /app/chat/
|
|
COPY notifier/pyproject.toml /app/notifier/
|
|
|
|
# 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
|
|
|
|
# Command to start Supervisor
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|