2021-03-13 10:24:44 +00:00
|
|
|
FROM node:current-alpine AS node-build
|
|
|
|
WORKDIR /etc/linkding
|
|
|
|
# install build dependencies
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
RUN npm install -g npm && \
|
|
|
|
npm install
|
|
|
|
# compile JS components
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
2019-07-03 15:18:29 +00:00
|
|
|
|
|
|
|
|
2022-09-04 08:05:29 +00:00
|
|
|
FROM python:3.10.6-slim-buster AS python-base
|
2023-01-12 20:00:58 +00:00
|
|
|
RUN apt-get update && apt-get -y install build-essential libpq-dev
|
2019-07-04 23:26:52 +00:00
|
|
|
WORKDIR /etc/linkding
|
2021-03-13 10:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM python-base AS python-build
|
|
|
|
# install build dependencies
|
|
|
|
COPY requirements.txt requirements.txt
|
|
|
|
RUN pip install -U pip && pip install -Ur requirements.txt
|
|
|
|
# run Django part of the build
|
|
|
|
COPY --from=node-build /etc/linkding .
|
|
|
|
RUN python manage.py compilescss && \
|
|
|
|
python manage.py collectstatic --ignore=*.scss && \
|
|
|
|
python manage.py compilescss --delete-files
|
|
|
|
|
|
|
|
|
|
|
|
FROM python-base AS prod-deps
|
2019-07-03 15:18:29 +00:00
|
|
|
COPY requirements.prod.txt ./requirements.txt
|
2021-03-13 10:24:44 +00:00
|
|
|
RUN mkdir /opt/venv && \
|
|
|
|
python -m venv --upgrade-deps --copies /opt/venv && \
|
|
|
|
/opt/venv/bin/pip install --upgrade pip wheel && \
|
|
|
|
/opt/venv/bin/pip install -Ur requirements.txt
|
2019-07-03 15:18:29 +00:00
|
|
|
|
2019-07-03 17:50:25 +00:00
|
|
|
|
2022-09-04 08:05:29 +00:00
|
|
|
FROM python:3.10.6-slim-buster as final
|
2023-01-12 20:00:58 +00:00
|
|
|
RUN apt-get update && apt-get -y install mime-support libpq-dev
|
2021-03-13 10:24:44 +00:00
|
|
|
WORKDIR /etc/linkding
|
|
|
|
# copy prod dependencies
|
|
|
|
COPY --from=prod-deps /opt/venv /opt/venv
|
|
|
|
# copy output from build stage
|
|
|
|
COPY --from=python-build /etc/linkding/static static/
|
|
|
|
# copy application code
|
|
|
|
COPY . .
|
2019-07-04 23:26:52 +00:00
|
|
|
# Expose uwsgi server at port 9090
|
2019-07-03 15:18:29 +00:00
|
|
|
EXPOSE 9090
|
2021-03-13 10:24:44 +00:00
|
|
|
# Activate virtual env
|
|
|
|
ENV VIRTUAL_ENV /opt/venv
|
|
|
|
ENV PATH /opt/venv/bin:$PATH
|
2021-08-16 07:16:24 +00:00
|
|
|
# Allow running containers as an an arbitrary user in the root group, to support deployment scenarios like OpenShift, Podman
|
|
|
|
RUN ["chmod", "g+w", "."]
|
2019-07-04 23:26:52 +00:00
|
|
|
# Run bootstrap logic
|
|
|
|
RUN ["chmod", "+x", "./bootstrap.sh"]
|
2019-07-03 15:18:29 +00:00
|
|
|
CMD ["./bootstrap.sh"]
|