Spaces:
Build error
Build error
# Node frontend build | |
FROM node:18 as builder | |
WORKDIR /usr/src/app | |
RUN --mount=type=secret,id=GH_PAT,mode=0444,required=true \ | |
git clone https://TomTom101:$(cat /run/secrets/GH_PAT)@github.com/TomTom101/use-case-voting . | |
WORKDIR /usr/src/app/frontend | |
RUN npm install | |
RUN npm run build | |
# Main build | |
FROM python:3.11-slim-bookworm | |
RUN useradd -m -u 1000 user | |
ENV POETRY_VERSION=1.6 \ | |
POETRY_VIRTUALENVS_CREATE=false | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
WORKDIR $HOME/app | |
USER root | |
RUN apt-get update \ | |
&& apt-get install nginx supervisor -y | |
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html | |
COPY --chown=user ./docker/nginx.prod.conf /etc/nginx/sites-available/default | |
COPY --chown=user ./docker/supervisord.conf /etc/supervisord.conf | |
# Create nginx folders | |
RUN mkdir -p /var/cache/nginx \ | |
/var/log/nginx \ | |
/var/lib/nginx | |
RUN touch /var/run/nginx.pid | |
RUN chown -R user:user \ | |
/var/cache/nginx \ | |
/var/log/nginx \ | |
/var/lib/nginx \ | |
/var/run/nginx.pid | |
RUN chown -R user:user $HOME/app | |
# Install poetry | |
RUN pip install "poetry==$POETRY_VERSION" | |
COPY --from=builder /usr/src/app/poetry.lock /usr/src/app/pyproject.toml /usr/src/app/README.md ./ | |
# Project initialization: | |
RUN poetry install --no-cache --no-interaction --no-ansi --no-root --without dev | |
COPY --from=builder /usr/src/app/use_case_voting ./use_case_voting | |
RUN poetry install --only-root | |
USER user | |
RUN touch $HOME/app/supervisord.pid | |
# Start nginx and FastAPI | |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] |