barker/docker/app/Dockerfile

54 lines
1.7 KiB
Docker
Raw Permalink Normal View History

FROM node:latest AS builder
RUN mkdir -p /app/bookie
COPY package.json /app/bookie/package.json
RUN cd /app/bookie \
&& npm install --unsafe-perm \
&& mv /app/bookie/node_modules / \
&& cd / \
&& rm -rf /app
ADD https://git.tanshu.com/api/v1/repos/tanshu/barker/tags /tags.json
RUN git clone --single-branch --depth 1 --branch latest https://git.tanshu.com/tanshu/barker.git /app
WORKDIR /app/bookie
RUN mv /node_modules /app/bookie/ \
&& /app/bookie/node_modules/.bin/ng build
FROM python:3.11
LABEL maintainer="Amritanshu <docker@tanshu.com>"
COPY pyproject.toml /app/pyproject.toml
RUN apt-get update && \
apt-get install -y locales && \
sed --in-place --expression='s/# en_IN UTF-8/en_IN UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales
ENV LANG en_IN
ENV LC_ALL en_IN
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python - && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
WORKDIR /app
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
COPY --from=builder /app/barker /app
COPY --from=builder /app/frontend /app/frontend
ENV PYTHONPATH=/app
EXPOSE 80
VOLUME /frontend
RUN chmod 777 /app/docker-entrypoint.sh \
&& ln -s /app/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh \
&& ln -s /app/docker-entrypoint.sh /
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["poetry", "run", "gunicorn", "barker.main:app", "--worker-class", "uvicorn.workers.UvicornWorker", "--config", "/app/gunicorn.conf.py", "--log-config", "/app/logging.conf"]