2024-09-28 14:13:07 +00:00
|
|
|
FROM node:20-alpine AS node-build
|
2021-03-13 10:24:44 +00:00
|
|
|
WORKDIR /etc/linkding
|
|
|
|
# install build dependencies
|
2024-09-13 21:19:47 +00:00
|
|
|
COPY rollup.config.mjs postcss.config.js package.json package-lock.json ./
|
2024-03-16 14:57:23 +00:00
|
|
|
RUN npm ci
|
2023-11-05 13:18:26 +00:00
|
|
|
# copy files needed for JS build
|
|
|
|
COPY bookmarks/frontend ./bookmarks/frontend
|
2024-09-13 21:19:47 +00:00
|
|
|
COPY bookmarks/styles ./bookmarks/styles
|
2023-11-05 13:18:26 +00:00
|
|
|
# run build
|
2021-03-13 10:24:44 +00:00
|
|
|
RUN npm run build
|
2019-07-03 15:18:29 +00:00
|
|
|
|
|
|
|
|
2024-09-28 14:13:07 +00:00
|
|
|
FROM python:3.12.6-alpine3.20 AS build-deps
|
2024-03-18 21:50:07 +00:00
|
|
|
# Add required packages
|
|
|
|
# alpine-sdk linux-headers pkgconfig: build Python packages from source
|
|
|
|
# libpq-dev: build Postgres client from source
|
|
|
|
# icu-dev sqlite-dev: build Sqlite ICU extension
|
|
|
|
# libffi-dev openssl-dev rust cargo: build Python cryptography from source
|
|
|
|
RUN apk update && apk add alpine-sdk linux-headers libpq-dev pkgconfig icu-dev sqlite-dev libffi-dev openssl-dev rust cargo
|
2019-07-04 23:26:52 +00:00
|
|
|
WORKDIR /etc/linkding
|
2024-09-28 14:13:07 +00:00
|
|
|
# install python dependencies
|
2021-03-13 10:24:44 +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
|
|
|
|
2024-09-28 14:13:07 +00:00
|
|
|
FROM build-deps AS compile-icu
|
2023-08-27 13:41:23 +00:00
|
|
|
# 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-09-19 17:15:51 +00:00
|
|
|
FROM python:3.12.6-alpine3.20 AS linkding
|
2024-08-28 20:57:58 +00:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/sissbruecker/linkding"
|
2023-11-05 13:18:26 +00:00
|
|
|
# install runtime dependencies
|
2024-03-18 21:50:07 +00:00
|
|
|
RUN apk update && apk add bash curl icu libpq mailcap libssl3
|
2023-11-05 13:18:26 +00:00
|
|
|
# create www-data user and group
|
|
|
|
RUN set -x ; \
|
|
|
|
addgroup -g 82 -S www-data ; \
|
|
|
|
adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
|
2021-03-13 10:24:44 +00:00
|
|
|
WORKDIR /etc/linkding
|
2024-09-28 14:13:07 +00:00
|
|
|
# copy python dependencies
|
|
|
|
COPY --from=build-deps /opt/venv /opt/venv
|
|
|
|
# copy output from node build
|
|
|
|
COPY --from=node-build /etc/linkding/bookmarks/static bookmarks/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 . .
|
2024-09-28 14:13:07 +00:00
|
|
|
# Activate virtual env
|
|
|
|
ENV VIRTUAL_ENV=/opt/venv
|
|
|
|
ENV PATH=/opt/venv/bin:$PATH
|
|
|
|
# Generate static files, remove source styles that are not needed
|
|
|
|
RUN mkdir data && \
|
|
|
|
python manage.py collectstatic
|
|
|
|
|
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-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
|
2023-11-05 13:18:26 +00:00
|
|
|
RUN chmod g+w . && \
|
|
|
|
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
|
|
|
|
|
|
|
|
2024-04-14 11:09:46 +00:00
|
|
|
FROM node:18-alpine AS ublock-build
|
|
|
|
WORKDIR /etc/linkding
|
|
|
|
# Install necessary tools
|
2024-09-29 12:42:50 +00:00
|
|
|
# Download and unzip the latest uBlock Origin Lite release
|
|
|
|
# Patch manifest to enable annoyances by default
|
|
|
|
# Patch ruleset-manager.js to use rulesets enabled in manifest by default
|
|
|
|
RUN apk add --no-cache curl jq unzip && \
|
|
|
|
TAG=$(curl -sL https://api.github.com/repos/uBlockOrigin/uBOL-home/releases/latest | jq -r '.tag_name') && \
|
|
|
|
DOWNLOAD_URL=https://github.com/uBlockOrigin/uBOL-home/releases/download/$TAG/$TAG.chromium.mv3.zip && \
|
|
|
|
echo "Downloading $DOWNLOAD_URL" && \
|
|
|
|
curl -L -o uBOLite.zip $DOWNLOAD_URL && \
|
|
|
|
unzip uBOLite.zip -d uBOLite.chromium.mv3 && \
|
|
|
|
rm uBOLite.zip && \
|
|
|
|
jq '.declarative_net_request.rule_resources |= map(if .id == "annoyances-overlays" or .id == "annoyances-cookies" or .id == "annoyances-social" or .id == "annoyances-widgets" or .id == "annoyances-others" then .enabled = true else . end)' \
|
|
|
|
uBOLite.chromium.mv3/manifest.json > temp.json && \
|
|
|
|
mv temp.json uBOLite.chromium.mv3/manifest.json && \
|
|
|
|
sed -i 's/const out = \[ '\''default'\'' \];/const out = await dnr.getEnabledRulesets();/' uBOLite.chromium.mv3/js/ruleset-manager.js
|
2024-04-14 11:09:46 +00:00
|
|
|
|
|
|
|
|
2024-04-01 13:19:38 +00:00
|
|
|
FROM linkding AS linkding-plus
|
2024-04-07 09:05:48 +00:00
|
|
|
# install node, chromium
|
|
|
|
RUN apk update && apk add nodejs npm chromium
|
|
|
|
# install single-file from fork for now, which contains several hotfixes
|
2024-04-14 11:09:46 +00:00
|
|
|
RUN npm install -g https://github.com/sissbruecker/single-file-cli/tarball/4c54b3bc704cfb3e96cec2d24854caca3df0b3b6
|
2024-09-29 12:42:50 +00:00
|
|
|
# copy uBlock
|
|
|
|
COPY --from=ublock-build /etc/linkding/uBOLite.chromium.mv3 uBOLite.chromium.mv3/
|
2024-10-02 19:47:32 +00:00
|
|
|
# create chromium profile folder for user running background tasks and set permissions
|
|
|
|
RUN mkdir -p chromium-profile && \
|
|
|
|
chown -R www-data:www-data chromium-profile && \
|
|
|
|
chown -R www-data:www-data uBOLite.chromium.mv3
|
2024-04-01 13:19:38 +00:00
|
|
|
# enable snapshot support
|
|
|
|
ENV LD_ENABLE_SNAPSHOTS=True
|