2024-03-18 21:50:07 +00:00
|
|
|
FROM node:18-alpine AS node-build
|
2021-03-13 10:24:44 +00:00
|
|
|
WORKDIR /etc/linkding
|
|
|
|
# install build dependencies
|
2024-03-16 14:57:23 +00:00
|
|
|
COPY rollup.config.mjs package.json package-lock.json ./
|
|
|
|
RUN npm ci
|
2023-11-05 13:18:26 +00:00
|
|
|
# copy files needed for JS build
|
|
|
|
COPY bookmarks/frontend ./bookmarks/frontend
|
|
|
|
# run build
|
2021-03-13 10:24:44 +00:00
|
|
|
RUN npm run build
|
2019-07-03 15:18:29 +00:00
|
|
|
|
|
|
|
|
2024-03-18 21:50:07 +00:00
|
|
|
# Use 3.11 for now, as django4-background-tasks doesn't work with 3.12 yet
|
|
|
|
FROM python:3.11.8-slim-bookworm AS python-base
|
|
|
|
# Add required packages
|
|
|
|
# build-essential pkg-config: build Python packages from source
|
|
|
|
# libpq-dev: build Postgres client from source
|
|
|
|
# libicu-dev libsqlite3-dev: build Sqlite ICU extension
|
|
|
|
# llibffi-dev libssl-dev curl rustup: build Python cryptography from source
|
|
|
|
RUN apt-get update && apt-get -y install build-essential pkg-config libpq-dev libicu-dev libsqlite3-dev wget unzip libffi-dev libssl-dev curl
|
|
|
|
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
|
|
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
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
|
2024-01-28 21:50:51 +00:00
|
|
|
COPY requirements.dev.txt requirements.dev.txt
|
2023-11-05 13:18:26 +00:00
|
|
|
# remove playwright from requirements as there is not always a distro and it's not needed for the build
|
2024-01-28 21:50:51 +00:00
|
|
|
RUN sed -i '/playwright/d' requirements.dev.txt
|
|
|
|
RUN pip install -U pip && pip install -r requirements.txt -r requirements.dev.txt
|
2023-11-05 13:18:26 +00:00
|
|
|
# copy files needed for Django build
|
|
|
|
COPY . .
|
2021-03-13 10:24:44 +00:00
|
|
|
COPY --from=node-build /etc/linkding .
|
2023-11-05 13:18:26 +00:00
|
|
|
# run Django part of the build
|
2024-04-07 09:11:14 +00:00
|
|
|
RUN mkdir data && \
|
|
|
|
python manage.py compilescss && \
|
2021-03-13 10:24:44 +00:00
|
|
|
python manage.py collectstatic --ignore=*.scss && \
|
|
|
|
python manage.py compilescss --delete-files
|
|
|
|
|
|
|
|
|
|
|
|
FROM python-base AS prod-deps
|
2024-01-28 21:50:51 +00:00
|
|
|
COPY requirements.txt ./requirements.txt
|
2024-03-18 21:50:07 +00:00
|
|
|
# Need to build psycopg2 from source for ARM platforms
|
2024-01-28 21:50:51 +00:00
|
|
|
RUN sed -i 's/psycopg2-binary/psycopg2/g' 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 && \
|
2024-01-28 21:50:51 +00:00
|
|
|
/opt/venv/bin/pip install -r requirements.txt
|
2019-07-03 15:18:29 +00:00
|
|
|
|
2019-07-03 17:50:25 +00:00
|
|
|
|
2023-08-27 13:41:23 +00:00
|
|
|
FROM python-base AS compile-icu
|
|
|
|
# Defines SQLite version
|
|
|
|
# Since this is only needed for downloading the header files this probably
|
|
|
|
# doesn't need to be up-to-date, assuming the SQLite APIs used by the ICU
|
|
|
|
# extension do not change
|
|
|
|
ARG SQLITE_RELEASE_YEAR=2023
|
|
|
|
ARG SQLITE_RELEASE=3430000
|
|
|
|
|
|
|
|
# Compile the ICU extension needed for case-insensitive search and ordering
|
|
|
|
# with SQLite. This does:
|
|
|
|
# - Download SQLite amalgamation for header files
|
|
|
|
# - Download ICU extension source file
|
|
|
|
# - Compile ICU extension
|
|
|
|
RUN wget https://www.sqlite.org/${SQLITE_RELEASE_YEAR}/sqlite-amalgamation-${SQLITE_RELEASE}.zip && \
|
|
|
|
unzip sqlite-amalgamation-${SQLITE_RELEASE}.zip && \
|
|
|
|
cp sqlite-amalgamation-${SQLITE_RELEASE}/sqlite3.h ./sqlite3.h && \
|
|
|
|
cp sqlite-amalgamation-${SQLITE_RELEASE}/sqlite3ext.h ./sqlite3ext.h && \
|
|
|
|
wget https://www.sqlite.org/src/raw/ext/icu/icu.c?name=91c021c7e3e8bbba286960810fa303295c622e323567b2e6def4ce58e4466e60 -O icu.c && \
|
|
|
|
gcc -fPIC -shared icu.c `pkg-config --libs --cflags icu-uc icu-io` -o libicu.so
|
|
|
|
|
|
|
|
|
2024-04-01 13:19:38 +00:00
|
|
|
FROM python:3.11.8-slim-bookworm as linkding
|
2024-03-18 21:50:07 +00:00
|
|
|
RUN apt-get update && apt-get -y install mime-support libpq-dev libicu-dev libssl3 curl
|
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/
|
2023-08-27 13:41:23 +00:00
|
|
|
# copy compiled icu extension
|
|
|
|
COPY --from=compile-icu /etc/linkding/libicu.so libicu.so
|
2021-03-13 10:24:44 +00:00
|
|
|
# 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"]
|
2023-01-20 21:26:58 +00:00
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --retries=3 --timeout=1s \
|
2023-02-18 17:36:57 +00:00
|
|
|
CMD curl -f http://localhost:${LD_SERVER_PORT:-9090}/${LD_CONTEXT_PATH}health || exit 1
|
2023-01-20 21:26:58 +00:00
|
|
|
|
2019-07-03 15:18:29 +00:00
|
|
|
CMD ["./bootstrap.sh"]
|
2024-04-01 13:19:38 +00:00
|
|
|
|
|
|
|
FROM linkding AS linkding-plus
|
2024-04-07 09:05:48 +00:00
|
|
|
# install chromium
|
|
|
|
RUN apt-get update && apt-get -y install chromium
|
|
|
|
# install node
|
|
|
|
ENV NODE_MAJOR=20
|
|
|
|
RUN apt-get install -y gnupg2 apt-transport-https ca-certificates && \
|
|
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg && \
|
|
|
|
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
|
|
|
apt-get update && apt-get install -y nodejs
|
|
|
|
# install single-file from fork for now, which contains several hotfixes
|
|
|
|
RUN npm install -g https://github.com/sissbruecker/single-file-cli/tarball/f3730995a52f27d5041a1ad9e7528af4b6b4cf4b
|
2024-04-01 13:19:38 +00:00
|
|
|
# enable snapshot support
|
|
|
|
ENV LD_ENABLE_SNAPSHOTS=True
|