mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 10:58:25 +02:00
Multistage Dockerfile (#90)
* Multistage Dockerfile * Fix final stage and improve image size + layer caching Co-authored-by: Sascha Ißbrücker <sissbruecker@lyska.io>
This commit is contained in:

committed by
GitHub

parent
6880c9ee56
commit
ad070e7019
@@ -5,13 +5,22 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/tmp
|
/tmp
|
||||||
/docs
|
/docs
|
||||||
|
/static
|
||||||
|
/build
|
||||||
|
|
||||||
/.dockerignore
|
/.dockerignore
|
||||||
/.gitignore
|
/.gitignore
|
||||||
/build-*.sh
|
|
||||||
/Dockerfile
|
/Dockerfile
|
||||||
|
/docker-compose.yml
|
||||||
|
/*.sh
|
||||||
/*.iml
|
/*.iml
|
||||||
/package*.json
|
/*.patch
|
||||||
|
/*.md
|
||||||
|
/*.js
|
||||||
|
|
||||||
|
# Whitelist files needed in build or prod image
|
||||||
|
!/rollup.config.js
|
||||||
|
!/bootstrap.sh
|
||||||
|
|
||||||
# Remove development settings
|
# Remove development settings
|
||||||
/siteroot/settings/dev.py
|
/siteroot/settings/dev.py
|
||||||
|
58
Dockerfile
58
Dockerfile
@@ -1,22 +1,52 @@
|
|||||||
FROM python:3.7-slim-stretch
|
FROM node:current-alpine AS node-build
|
||||||
|
|
||||||
# Install packages required for uswgi
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get -y install build-essential
|
|
||||||
RUN apt-get -y install mime-support
|
|
||||||
|
|
||||||
# Install requirements and uwsgi server for running python web apps
|
|
||||||
WORKDIR /etc/linkding
|
WORKDIR /etc/linkding
|
||||||
COPY requirements.prod.txt ./requirements.txt
|
# install build dependencies
|
||||||
RUN pip install -U pip
|
COPY package.json package-lock.json ./
|
||||||
RUN pip install -Ur requirements.txt
|
RUN npm install -g npm && \
|
||||||
|
npm install
|
||||||
# Copy application
|
# compile JS components
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.9-slim AS python-base
|
||||||
|
RUN apt-get update && apt-get -y install build-essential
|
||||||
|
WORKDIR /etc/linkding
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
COPY requirements.prod.txt ./requirements.txt
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.9-slim as final
|
||||||
|
RUN apt-get update && apt-get -y install mime-support
|
||||||
|
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 . .
|
||||||
# Expose uwsgi server at port 9090
|
# Expose uwsgi server at port 9090
|
||||||
EXPOSE 9090
|
EXPOSE 9090
|
||||||
|
# Activate virtual env
|
||||||
|
ENV VIRTUAL_ENV /opt/venv
|
||||||
|
ENV PATH /opt/venv/bin:$PATH
|
||||||
# Run bootstrap logic
|
# Run bootstrap logic
|
||||||
RUN ["chmod", "+x", "./bootstrap.sh"]
|
RUN ["chmod", "+x", "./bootstrap.sh"]
|
||||||
CMD ["./bootstrap.sh"]
|
CMD ["./bootstrap.sh"]
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
beautifulsoup4==4.7.1
|
beautifulsoup4==4.7.1
|
||||||
certifi==2019.6.16
|
certifi==2019.6.16
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
|
confusable-homoglyphs==3.2.0
|
||||||
Django==2.2.13
|
Django==2.2.13
|
||||||
django-appconf==1.0.3
|
|
||||||
django-compressor==2.3
|
|
||||||
django-generate-secret-key==1.0.2
|
django-generate-secret-key==1.0.2
|
||||||
django-picklefield==2.0
|
django-picklefield==2.0
|
||||||
django-registration==3.0.1
|
django-registration==3.0.1
|
||||||
@@ -13,10 +12,7 @@ djangorestframework==3.11.1
|
|||||||
idna==2.8
|
idna==2.8
|
||||||
pyparsing==2.4.7
|
pyparsing==2.4.7
|
||||||
pytz==2019.1
|
pytz==2019.1
|
||||||
rcssmin==1.0.6
|
|
||||||
requests==2.22.0
|
requests==2.22.0
|
||||||
rjsmin==1.1.0
|
|
||||||
six==1.12.0
|
|
||||||
soupsieve==1.9.2
|
soupsieve==1.9.2
|
||||||
sqlparse==0.3.0
|
sqlparse==0.3.0
|
||||||
urllib3==1.25.3
|
urllib3==1.25.3
|
||||||
|
Reference in New Issue
Block a user