Skip to content

Commit 7da1846

Browse files
Merge pull request #7 from supertokens/docker-for-testing
dockerfile and scripts to create docker image locally
2 parents 0b8d71b + b4a5ca6 commit 7da1846

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

docker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker-entrypoint.sh

docker/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ubuntu:bionic-20200219 as tmp
2+
RUN mkdir supertokens
3+
WORKDIR supertokens
4+
COPY core core
5+
COPY cli cli
6+
COPY downloader downloader
7+
COPY plugin-interface plugin-interface
8+
COPY plugin plugin
9+
COPY install ./
10+
COPY config.yaml ./
11+
COPY config.yaml config.yaml.original
12+
COPY jre jre
13+
COPY version.yaml ./
14+
RUN ./install
15+
FROM debian:stable-slim
16+
RUN groupadd supertokens && useradd -m -s /bin/bash -g supertokens supertokens
17+
RUN apt-get update && apt-get install -y --no-install-recommends gnupg dirmngr && rm -rf /var/lib/apt/lists/*
18+
ENV GOSU_VERSION 1.7
19+
RUN set -x \
20+
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
21+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
22+
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
23+
&& export GNUPGHOME="$(mktemp -d)" \
24+
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
25+
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
26+
&& gpgconf --kill all \
27+
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
28+
&& chmod +x /usr/local/bin/gosu \
29+
&& apt-get purge -y --auto-remove ca-certificates wget
30+
COPY --from=tmp --chown=supertokens /usr/lib/supertokens /usr/lib/supertokens
31+
COPY --from=tmp --chown=supertokens /usr/bin/supertokens /usr/bin/supertokens
32+
COPY docker-entrypoint.sh /usr/local/bin/
33+
RUN echo "$(md5sum /usr/lib/supertokens/config.yaml | awk '{ print $1 }')" >> /CONFIG_HASH
34+
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
35+
EXPOSE 3567
36+
ENTRYPOINT ["docker-entrypoint.sh"]
37+
CMD ["supertokens", "start"]

docker/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Docker image for testing
2+
3+
- the script `createPostgresqlImage.sh` here is used to create docker image with postgresql plugin.
4+
- Before the user runs this script, they need to start the testing env (i.e. `./startTestingEnv --wait`).
5+
- This script can only be used for postgresql plugin. No other plugin is supported. So before running the script, make sure to switch to postgresql-plugin in the `modules.txt`.
6+
7+
8+
### What the script is doing?
9+
- it fetches the required **jre** (based on your system architecture) and **docker-entrypoint.sh** from github.
10+
- copies the required cli, core, plugin, etc. from the parent directory into this folder
11+
- creates docker image with tag `supertokens-postgresql-testing`
12+
- removes all the copied/fetched files and folders

docker/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
core_config_version: 0
2+
postgresql_config_version: 0

docker/createPostgresqlImage.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## getting information regarding the machine architecture
2+
OS= && dpkgArch="$(uname -m)"
3+
case "${dpkgArch##*-}" in
4+
amd64) OS='linux';;
5+
x86_64) OS='linux';;
6+
arm64) OS='linux-arm';;
7+
*) OS='linux';;
8+
esac
9+
10+
## fetching the appropriate jre from github
11+
curl -o jre.zip -s -X GET \
12+
"https://raw.githubusercontent.com/supertokens/jre/master/jre-15.0.1-${OS}.zip"
13+
14+
## fetching docker-entrypoint.sh from github if file doesn't exists
15+
if [ ! -f docker-entrypoint.sh ]; then
16+
curl -o docker-entrypoint.sh -s -X GET \
17+
"https://raw.githubusercontent.com/supertokens/supertokens-docker-postgresql/master/docker-entrypoint.sh"
18+
fi
19+
20+
## marking docker-entrypoint.sh as executable
21+
chmod +x docker-entrypoint.sh
22+
23+
## unzipping the jre zip and removing the zip file once extracted
24+
unzip jre.zip && mv jre-* jre && rm -rf jre.zip
25+
26+
rm -rf __MACOSX
27+
28+
## copying all the necessary files and folders
29+
cp -r ../core core
30+
cp -r ../cli cli
31+
cp -r ../downloader downloader
32+
cp -r ../plugin-interface plugin-interface
33+
cp -r ../plugin plugin
34+
cp -r ../install ./
35+
cp -r ../version.yaml ./
36+
37+
## building the docker image
38+
docker build -t supertokens-postgresql-testing .
39+
40+
## removing all the files and folders previously copied or extracted
41+
rm -rf core
42+
rm -rf cli
43+
rm -rf downloader
44+
rm -rf plugin-interface
45+
rm -rf plugin
46+
rm -rf install
47+
rm -rf version.yaml
48+
rm -rf jre

0 commit comments

Comments
 (0)