- 
                Notifications
    You must be signed in to change notification settings 
- Fork 628
Building from source
        Rishabh Poddar edited this page Oct 7, 2020 
        ·
        13 revisions
      
    Building from source can allow you to customise SuperTokens as per your needs. This is recommended only for advanced users who are experts in authentication and security.
- Please follow the CONTRIBUTING.md file for instructions on how to setup a development environment, make changes to the code and run tests.
- Make sure you are in the supertokens-rootfolder, and havesupertokens-core,supertokens-plugin-interfaceand a SuperTokens plugin repo in it.
- Run ./startTestingEnv --wait
- Open a new terminal in supertokens-rootand runls. Make sure you seeinstall,corefolder,pluginfolder and theplugin-interfacefolder.
- Run cp ./supertokens-core/config.yaml ./
- To install SuperTokens on your machine, run java -classpath "./cli/*" io.supertokens.cli.Main true $@(you may need to usesudo, but first try without it)
- You can kill the process started in step 3. This should also remove the files / folders mentioned in step 4.
- Check that SuperTokens is installed by running supertokens
- To uninstall SuperTokens, run supertokens uninstall
Due to the code architecture, one docker image only works with one database. For example, you can build a docker image that has SuperTokens and works with a MySQL database, or one that only works with MongoDB. In fact, we distribute a docker image for each supported database.
To build your own:
- Please follow the CONTRIBUTING.md file for instructions on how to setup a development environment, make changes to the code and run tests.
- Find the correct docker repo (for your database). For example, if you want to build a docker image with MySQL, there will be a repository called supertokens-docker-mysql
- Clone the repo you found in the previous step and make sure that it's side-by-side to the supertokens-rootfolder.
- Copy the supertokens-rootfolder into the cloned directory. For example, if building for MySQL, runcp -rf ./supertokens-root ./supertokens-docker-mysql
- Download the linux JRE from supertokens-jre, extract the ZIP, rename the folder to jreand put it in the copiedsupertokens-rootfolder.
- Go into the copied supertokens-rootfolder and run./startTestingEnv --wait
- Open a new terminal in the cloned docker repo, and run cp supertokens-root/supertokens-core/config.yaml supertokens-root/
- Open the Dockerfilein an editor.
- Remove the following lines (should be line number 2 onwards):
ARG PLUGIN_NAME=mysql ARG PLAN_TYPE=FREE ARG CORE_VERSION=2.4.0 ARG PLUGIN_VERSION=1.3.0 RUN apt-get update && apt-get install -y curl zip RUN curl -o supertokens.zip -s -X GET \ "https://api.supertokens.io/0/app/download?pluginName=$PLUGIN_NAME&os=linux&mode=DEV&binary=$PLAN_TYPE&targetCore=$CORE_VERSION&targetPlugin=$PLUGIN_VERSION" \ -H "api-version: 0" RUN unzip supertokens.zip RUN cd supertokens && ./install
- Replace the above lines with:
RUN mkdir ./supertokens COPY ./supertokens-root/ ./supertokens RUN cd supertokens && ./jre/bin/java -classpath "./cli/*" io.supertokens.cli.Main true
- Run the docker build command: docker build -t supertokens .
- Start the docker container (default to using in-memory database): docker run -p 3567:3567 supertokens