Robic’s API is divided into three layers:
Robic uses a number of environment variables to prevent sensitive environment variables being exposed to a public codebase such as this. To setup your local environment for development, you will need to set the following environment variables:
TokenKey
- secret token used for password hashingMySQLConnectionString
- MySQL database connection stringThis can be prefixed prior to calling dotnet watch run
.
i.e.
TokenKey="123abc" \
MySQLConnectionString="123abc" \
dotnet run
For simplicity’s sake, we keep this in startup.sh
(omitted from Git)
# from api directory
cd /api
# build Docker image
docker build -t ryanachten/robic -f .\Dockerfile .
# run Docker container available on http://localhost:5000/
docker run -it --rm -e TokenKey=$env:TokenKey -e MySQLConnectionString=$env:MySQLConnectionString -p 5000:80 ryanachten/robic
# push changes to Docker Hub if things are looking good (requires Docker Hub login)
docker login
docker push ryanachten/robic
To run with Android, we need to reference local ports using http://10.0.2.2:PORT
- see here for more information.
To run with iOS simulator, we need to run the server in HTTPS. However, iOS does not seem to work with localhost
domains when running .NET Core locally. To work around this, we route the local server using ngrok.
Steps:
dotnet watch run
ngrok http https://localhost:5001