Skip to content

Commit 5948453

Browse files
committed
Change entrypoint in Dockerfile so that we can start the appservice.
We could have used another Dockerfile for the appservice, extending the exising one but we decided not to because there would have been lots of fiddling around the entrypoint and logistics involved around adding a tag for it via github actions. Not to mention that this would be duplicating the image just to run it with a different binary. This solution is much simpler, backwards compatible, and conscious about the future.
1 parent 91082ba commit 5948453

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
FROM node:16-alpine
1+
# We can't use alpine anymore because crypto has rust deps.
2+
FROM node:16-slim
23
COPY . /tmp/src
34
RUN cd /tmp/src \
45
&& yarn install \
56
&& yarn build \
67
&& mv lib/ /mjolnir/ \
78
&& mv node_modules / \
9+
&& mv mjolnir-entrypoint.sh / \
810
&& cd / \
911
&& rm -rf /tmp/*
1012

1113
ENV NODE_ENV=production
1214
ENV NODE_CONFIG_DIR=/data/config
1315

14-
CMD node /mjolnir/index.js
16+
CMD ["bot"]
17+
ENTRYPOINT ["./mjolnir-entrypoint.sh"]
1518
VOLUME ["/data"]

mjolnir-entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# This is used as the entrypoint in the mjolnir Dockerfile.
4+
# We want to transition away form people running the image without specifying `bot` or `appservice`.
5+
# So if eventually cli arguments are provided for the bot version, we want this to be the opportunity to move to `bot`.
6+
# Therefore using arguments without specifying `bot` (or appservice) is unsupported.
7+
# We maintain the behaviour where if it looks like someone is providing an executable to `docker run`, then we will execute that instead.
8+
# This aids configuration and debugging of the image if for example node needed to be started via another method.
9+
case "$1" in
10+
bot) shift; set -- node /mjolnir/index.js "$@";;
11+
appservice) shift; set -- node /mjolnir/appservice/cli.js "$@";;
12+
esac
13+
14+
exec "$@";

0 commit comments

Comments
 (0)