diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..dd8e8438 --- /dev/null +++ b/.env.example @@ -0,0 +1,36 @@ +# MongoDB Credentials for the local Docker container +MONGO_USERNAME=root +MONGO_PASSWORD=root + +# Mongo-Express UI Credentials +MONGO_EXPRESS_USERNAME=admin +MONGO_EXPRESS_PASSWORD=admin + +# Rerum server settings +PORT=3001 +RERUM_API_VERSION=1.0.0 +COLLECTION_ACCEPTEDSERVER=acceptedServer +COLLECTION_V0=annotation +AUDIENCE=http://rerum.io/api +ISSUER_BASE_URL=https://example.auth0.com/ +RERUM_BASE=http://localhost:3001 +RERUM_PREFIX=http://localhost:3001/v1/ +RERUM_ID_PREFIX=http://localhost:3001/v1/id/ +RERUM_AGENT_CLAIM=http://store.rerum.io/agent +RERUM_CONTEXT=http://store.rerum.io/v1/context.json +RERUM_API_DOC=http://localhost:3001/v1/API.html + +# The local MongoDB connection string +MONGO_CONNECTION_STRING=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@mongo:27017/ +MONGODBNAME=annotationStore +MONGODBCOLLECTION=alpha + +# Read only mode +DOWN=false +READONLY=false + +# Auth0 and bot secrets (replace with fake values for local use) +CLIENT_ID=dummy_client_id +CLIENT_SECRET=dummy_client_secret +BOT_TOKEN=dummy_bot_token +BOT_AGENT=http://devstore.rerum.io/v1/id/dummy_agent diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..efa6f43e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ + +FROM node + +# Set the working directory inside the container. +WORKDIR /app + +# Copy package.json and package-lock.json first to leverage Docker's build cache. +COPY package*.json ./ + +# Install application dependencies. +RUN npm install + +# Copy the rest of the application code. +COPY . . + +# Expose the port the app runs on. +EXPOSE 3001 + +# The command to start the application. +CMD ["node", "./bin/rerum_v1.js"] \ No newline at end of file diff --git a/README.md b/README.md index 603df373..7db3ca49 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,44 @@ MONGODBCOLLECTION = OBTAINED_FROM_MONGODB_SET_UP DOWN = false READONLY = false ``` +#### Add .env.example instructions +##### Using `.env.example` for Community Testing +To allow the application to run safely without exposing secrets: +1. Copy the example environment file to `.env`: + ```bash + cp .env.example .env +2. .env.example contains dummy values for all required variables. You do not need real credentials to run the app locally. +3. Note: + Write actions (create, update, delete) may not work without valid Auth0 credentials. + You can still explore the API, MongoDB, and UI for testing purposes. + #### Instructions + 1. Running the RERUM API with Docker + Ensure Docker and Docker Compose are installed. + Copy the example environment file: + bash + Copy code + cp .env.example .env + + 2. Build and start the containers: + bash + Copy code + docker-compose up --build + +Services will be available at: +RERUM API → http://localhost:3001 +Mongo Express → http://localhost:8081 +Local Auth0 → http://localhost:3002 + + 3. To stop the containers: + bash + Copy code + docker-compose down + +4. This setup uses dummy credentials so the API runs safely. For full Auth0 functionality, replace the dummy values in .env with real credentials. +5. The .env.example file contains safe dummy credentials: + Auth0 CLIENT_ID, CLIENT_SECRET + Bot tokens +6. You can safely run the application with these values without affecting real data. #### Set Up Auth0 Authorization Please contact the [Research Computing Group at Saint Louis University](https://github.com/CenterForDigitalHumanities) via an E-mail to research.computing@slu.edu for more information and assistance with this step of the installation process. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..de8292e6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,59 @@ +services: + rerum: + build: . + container_name: rerum-server + restart: always + ports: + - "3001:3001" + env_file: .env + environment: + - MONGO_CONNECTION_STRING=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@mongo:27017/ + depends_on: + - localauth0 # Restored dependency on localauth0 + - mongo + + mongo: + image: mongo + container_name: rerum-mongo + restart: always + ports: + - "27017:27017" + volumes: + - mongo-data:/data/db + environment: + - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME} + - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD} + + mongo-express: + image: mongo-express + container_name: rerum-mongo-express + restart: always + ports: + - "8081:8081" + environment: + - ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_USERNAME} + - ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_PASSWORD} + - ME_CONFIG_MONGODB_URL=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@mongo:27017/ + - ME_CONFIG_BASICAUTH_USERNAME=${MONGO_EXPRESS_USERNAME} + - ME_CONFIG_BASICAUTH_PASSWORD=${MONGO_EXPRESS_PASSWORD} + depends_on: + - mongo + + # RESTORED SERVICE - Uses port 3002 and includes the debugging command + localauth0: + image: public.ecr.aws/primaassicurazioni/localauth0:0.8.2 + container_name: rerum-localauth0 + restart: always + healthcheck: + test: ["CMD", "/localauth0", "healthcheck"] + ports: + - "3002:3002" + env_file: .env + depends_on: + - mongo + # CRITICAL DEBUGGING STEP: Forces the application to run in the foreground. + # This will dump the startup error (which is causing ERR_EMPTY_RESPONSE) directly to your console. + command: /localauth0 + +volumes: + mongo-data: