-
Notifications
You must be signed in to change notification settings - Fork 185
ARM and Raspberry Pi Support for Docker builds
Shyam Sunder edited this page Sep 19, 2021
·
5 revisions
As of commit c3b8137, Docker Hub now hosts images for linux/amd64
, linux/arm/v7
, and linux/arm64
, meaning no changes should be needed to the install instructions for szurubooru to work on a Raspberry Pi. Note the following issues reported by users however:
-
While the
postgres:11-alpine
recommended by this project should work, one user found better success using Postgres (v13). See #410 -
Alpine 3.13 isn't compatible by default with Raspbian and requires an update to
libseccomp2
(See here):
$ wget http://ftp.de.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
$ dpkg -i libseccomp2_2.5.1-1_armhf.deb
- If there is demand for additional build platforms to be included, please open an issue
Here are my files! If this isn't enough let me know, I might've forgotten one. Again, this is only for rpi3/arm32v7
replace all of the [name] and [password] with your own!
Client/Dockerfile
FROM arm32v7/node:9 as builder
WORKDIR /opt/app
COPY package.json ./
RUN npm install
COPY . ./
ARG BUILD_INFO="docker-latest"
ARG CLIENT_BUILD_ARGS=""
RUN BASE_URL="__BASEURL__" node build.js --gzip ${CLIENT_BUILD_ARGS}
FROM tobi312/rpi-nginx:alpine
WORKDIR /var/www
RUN \
# Create init file
echo "#!/bin/sh" >> /init && \
echo 'sed -i "s|__BACKEND__|${BACKEND_HOST}|" /etc/nginx/nginx.conf' >> /init && \
echo 'sed -i "s|__BASEURL__|${BASE_URL:-/}|g" /var/www/index.htm /var/www/manifest.json' >> /init && \
echo 'exec nginx' >> /init && \
chmod a+x /init
CMD ["/init"]
VOLUME ["/data"]
COPY nginx.conf.docker /etc/nginx/nginx.conf
COPY --from=builder /opt/app/public/ .
Server/Dockerfile
FROM scratch as approot
WORKDIR /opt/app
COPY alembic.ini wait-for-es generate-thumb ./
COPY szurubooru/ ./szurubooru/
COPY config.yaml.dist ./
FROM python:3.6-slim
WORKDIR /opt/app
ARG PUID=1000
ARG PGID=1000
ARG PORT=6666
RUN \
# Set users
mkdir -p /opt/app /data && \
groupadd -g ${PGID} app && \
useradd -d /opt/app -M -c '' -g app -r -u ${PUID} app && \
chown -R app:app /opt/app /data && \
# Create init file
echo "#!/bin/sh" >> /init && \
echo "set -e" >> /init && \
echo "cd /opt/app" >> /init && \
echo "./wait-for-es" >> /init && \
echo "alembic upgrade head" >> /init && \
echo "exec waitress-serve --port ${PORT} szurubooru.facade:app" \
>> /init && \
chmod a+x /init && \
# Install ffmpeg
apt-get -yqq update && \
apt-get -yq install --no-install-recommends ffmpeg libpq-dev make gcc libffi-dev zlib1g-dev libjpeg-dev libtiff-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl-dev && \
rm -rf /var/lib/apt/lists/* && \
# Install waitress
pip3 install --no-cache-dir waitress
COPY --chown=app:app requirements.txt ./requirements.txt
RUN pip3 install --no-cache-dir -r ./requirements.txt
# done to minimize number of layers in final image
COPY --chown=app:app --from=approot / /
VOLUME ["/data/"]
EXPOSE ${PORT}
USER app
CMD ["/init"]
.env
# Database credentials
POSTGRES_USER=[name]
POSTGRES_PASSWORD=[password]
# This shows up on the homescreen, indicating build information
BUILD_INFO=latest
# Port to expose HTTP service
PORT=[port]
# Directory to store image data
## remember to chmod this directory
MOUNT_DATA=/var/local/[name]/data
# Directory to store database files
MOUNT_SQL=/var/local/[name]/sql
requirements.txt
alembic>=0.8.5
pyyaml>=3.11
psycopg2-binary>=2.6.1
SQLAlchemy>=1.0.12
coloredlogs==5.0
elasticsearch>=5.0.0
elasticsearch-dsl>=5.0.0
numpy>=1.8.2
pillow>=4.3.0
pynacl==1.2.1
pytz>=2018.3
pyRFC3339>=1.0
docker-compose.yml;
## Example Docker Compose configuration
##
## Use this as a template to set up docker-compose, or as guide to set up other
## orchestration services
version: '2'
services:
api:
build:
context: ./server
depends_on:
- sql
- elasticsearch
environment:
## These should be the names of the dependent containers listed above,
## or FQDNs/IP addresses if these services are running outside of Docker
POSTGRES_HOST: sql
ESEARCH_HOST: elasticsearch
## Credentials for database:
POSTGRES_USER: [Name]
POSTGRES_PASSWORD: [pass]
## Commented Values are Default:
#POSTGRES_DB: defaults to same as POSTGRES_USER
#POSTGRES_PORT: 5432
#ESEARCH_PORT: 9200
#ESEARCH_INDEX: szurubooru
#LOG_SQL: 0 (1 for verbose SQL logs)
volumes:
- "${MOUNT_DATA}:/data"
- "./server/config.yaml:/opt/app/config.yaml"
client:
build:
context: ./client
args:
BUILD_INFO:
depends_on:
- api
environment:
BACKEND_HOST: api
volumes:
- "${MOUNT_DATA}:/data:ro"
ports:
- "${PORT}:80"
sql:
image: postgres:alpine
restart: unless-stopped
environment:
POSTGRES_USER: [name]
POSTGRES_PASSWORD: [pass]
volumes:
- "${MOUNT_SQL}:/var/lib/postgresql/data"
elasticsearch:
image: ind3x/rpi-elasticsearch
environment:
## Specifies the Java heap size used
## Read
## https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
## for more info
ES_JAVA_OPTS: -Xms512m -Xmx512m
volumes:
- index:/usr/share/elasticsearch/data
volumes:
index: # Scratch space for ElasticSearch index, will be rebuilt if lost