forked from fair/matrix-puppeteer-line
* Update Dockerfiles to work properly * Use latest available version of Alpine Linux * Update Puppeteer to 9.1.1 to match Chrome version available in latest Alpine Linux * Add docker script for Node process to allow custom config * Provide separate example config for running Node in docker TODO: Update SETUP.md with Docker instructionsmaster
parent
570eedf904
commit
be1ec0217c
@ -1,49 +1,46 @@ |
||||
FROM alpine:3.12 |
||||
FROM alpine:3.14 |
||||
|
||||
ARG TARGETARCH=amd64 |
||||
|
||||
RUN echo $'\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories |
||||
|
||||
RUN apk add --no-cache \ |
||||
python3 py3-pip py3-setuptools py3-wheel \ |
||||
py3-virtualenv \ |
||||
py3-pillow \ |
||||
py3-aiohttp \ |
||||
py3-magic \ |
||||
py3-ruamel.yaml \ |
||||
py3-commonmark@edge \ |
||||
# Other dependencies |
||||
ca-certificates \ |
||||
su-exec \ |
||||
py3-commonmark \ |
||||
# encryption |
||||
olm-dev \ |
||||
py3-olm \ |
||||
py3-cffi \ |
||||
py3-pycryptodome \ |
||||
py3-pycryptodome \ |
||||
py3-unpaddedbase64 \ |
||||
py3-future \ |
||||
# Other dependencies |
||||
ca-certificates \ |
||||
bash \ |
||||
curl \ |
||||
jq && \ |
||||
curl -sLo yq https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_${TARGETARCH} && \ |
||||
chmod +x yq && mv yq /usr/bin/yq |
||||
|
||||
jq \ |
||||
yq |
||||
|
||||
COPY requirements.txt /opt/matrix-puppeteer-line/requirements.txt |
||||
COPY optional-requirements.txt /opt/matrix-puppeteer-line/optional-requirements.txt |
||||
WORKDIR /opt/matrix-puppeteer-line |
||||
|
||||
COPY requirements.txt optional-requirements.txt ./ |
||||
RUN apk add --virtual .build-deps python3-dev libffi-dev build-base \ |
||||
&& pip3 install -r requirements.txt -r optional-requirements.txt \ |
||||
&& apk del .build-deps |
||||
|
||||
COPY . /opt/matrix-puppeteer-line |
||||
RUN apk add git && pip3 install .[e2be] && apk del git \ |
||||
COPY LICENSE setup.py ./ |
||||
COPY matrix_puppeteer_line matrix_puppeteer_line |
||||
RUN apk add --no-cache git && pip3 install .[e2be] && apk del git \ |
||||
# This doesn't make the image smaller, but it's needed so that the `version` command works properly |
||||
&& cp matrix_puppeteer_line/example-config.yaml . && rm -rf matrix_puppeteer_line |
||||
|
||||
VOLUME /data |
||||
ENV UID=1337 GID=1337 |
||||
|
||||
CMD ["/opt/matrix-puppeteer-line/docker-run.sh"] |
||||
# Needed to prevent "KeyError: 'getpwuid(): uid not found: 1337'" when connecting to postgres |
||||
RUN adduser -DHu 1337 --gecos "" line |
||||
|
||||
COPY docker-run.sh ./ |
||||
RUN chown -R 1337:1337 . |
||||
USER 1337 |
||||
CMD ["./docker-run.sh"] |
@ -1,17 +1,22 @@ |
||||
FROM node:14-alpine3.12 |
||||
FROM node:16-alpine3.14 |
||||
|
||||
RUN echo $'\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\ |
||||
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories |
||||
ARG TARGETARCH=amd64 |
||||
|
||||
RUN apk add --no-cache chromium@edge |
||||
RUN apk add --no-cache chromium xvfb-run xdotool |
||||
|
||||
WORKDIR /opt/matrix-puppeteer-line/puppet |
||||
RUN chown node:node /opt/matrix-puppeteer-line/puppet |
||||
USER node |
||||
|
||||
# Want to use same UID as Python process so the Unix socket can be shared. |
||||
# But yarn hits snags if there is no user for the UID it's run under. |
||||
RUN adduser -Du 1337 --gecos "" line |
||||
|
||||
VOLUME /data |
||||
|
||||
RUN chown 1337:1337 . |
||||
USER 1337 |
||||
COPY package.json yarn.lock ./ |
||||
RUN yarn --production && rm -rf node_modules/puppeteer/.local-chromium |
||||
|
||||
COPY . /opt/matrix-puppeteer-line/puppet |
||||
CMD ["yarn", "start", "--config", "/data/config.json", "--browser", "/usr/lib/chromium/chrome", "--no-sandbox"] |
||||
COPY src src |
||||
COPY docker-run.sh example-config-docker.json ./ |
||||
CMD ["./docker-run.sh"] |
@ -0,0 +1,18 @@ |
||||
#!/bin/sh |
||||
|
||||
if [ ! -w . ]; then |
||||
echo "Please ensure the /data volume of this container is writable for user:group $UID:$GID." >&2 |
||||
exit |
||||
fi |
||||
|
||||
if [ ! -f /data/config.json ]; then |
||||
cp example-config-docker.json /data/config.json |
||||
echo "Didn't find a config file." |
||||
echo "Copied default config file to /data/config.json" |
||||
echo "Modify that config file to your liking, then restart the container." |
||||
exit |
||||
fi |
||||
|
||||
# Allow setting custom browser path via "executable_path" config setting |
||||
# TODO Decide if --no-sandbox is needed |
||||
xvfb-run yarn start --config /data/config.json |
@ -0,0 +1,13 @@ |
||||
{ |
||||
"listen": { |
||||
"type": "unix", |
||||
"path": "/data/puppet.sock" |
||||
}, |
||||
"executable_path": "/usr/lib/chromium/chrome", |
||||
"profile_dir": "./profiles", |
||||
"extension_dir": "/data/extension_files", |
||||
"cycle_delay": 5000, |
||||
"use_xdotool": true, |
||||
"jiggle_delay": 20000, |
||||
"devtools": false |
||||
} |
Loading…
Reference in new issue