Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerify the AmbassadorBot #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ruby:2.4.1-alpine

LABEL maintainer="https://github.com/mbilokonsky/ambassador" \
description="A mastodon bot for showing the world the best your instance has to offer."

ENV UID=992 GID=992

WORKDIR /ambassador

RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& apk -U upgrade \
&& apk add -t build-dependencies \
build-base \
postgresql-dev \
&& apk add \
nodejs-npm@edge \
nodejs@edge \
su-exec \
tini \
&& npm install -g npm@3 && npm install -g yarn \
&& update-ca-certificates \
&& rm -rf /tmp/* /var/cache/apk/*

COPY index.js package.json yarn.lock /ambassador/

RUN yarn

COPY docker_entrypoint.sh /usr/local/bin/run

RUN chmod +x /usr/local/bin/run

ENTRYPOINT ["/usr/local/bin/run"]
12 changes: 12 additions & 0 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

echo "Creating ambassador user (UID : ${UID} and GID : ${GID})..."
addgroup -g ${GID} ambassador && adduser -h /ambassador -s /bin/sh -D -G ambassador -u ${UID} ambassador

echo "Updating permissions..."
chown -R ambassador:ambassador /ambassador

echo "Executing process..."
cd /ambassador
exec su-exec ambassador:ambassador /sbin/tini -- "$@"

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"pm2": "^2.4.4"
},
"scripts": {
"start": "pm2 start index.js",
"restart": "pm2 restart index"
"start": "pm2 start --no-daemon index.js",
"restart": "pm2 restart --no-daemon index"
}
}