py-builder-too
This commit is contained in:
87
Dockerfile
87
Dockerfile
@@ -1,22 +1,83 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:slim
|
||||
# Python builder stage
|
||||
FROM python:alpine3.18 AS py-builder
|
||||
|
||||
# Set the working directory in the container to /app
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Add metadata to the image to describe that the container is listening on port 80
|
||||
EXPOSE 8000
|
||||
# Copy only the pyproject.toml files
|
||||
COPY core/pyproject.toml /app/core/
|
||||
COPY chat/pyproject.toml /app/chat/
|
||||
COPY notifier/pyproject.toml /app/notifier/
|
||||
|
||||
# Copy the current directory contents into the container at /app
|
||||
COPY . /app
|
||||
# Install system dependencies
|
||||
RUN apk update && apk add --no-cache \
|
||||
gcc \
|
||||
curl \
|
||||
git
|
||||
|
||||
# Install any needed packages specified in pyproject.toml
|
||||
RUN apt-get update && apt-get install -y gcc curl && \
|
||||
curl -sSL https://install.python-poetry.org | python - && \
|
||||
echo "export PATH=$PATH:/root/.local/bin" >> ~/.bashrc && \
|
||||
# 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
|
||||
|
||||
# Run server when the container launches
|
||||
CMD granian --no-ws --host 0.0.0.0 --port 8000 --interface asgi main:app
|
||||
# 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"]
|
||||
|
Reference in New Issue
Block a user