diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cb5659d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js image as our base image +From node:18-alpine + +# Set the working directory in the container +WORKDIR /usr/src/app + +# copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install dependencies in the container +RUN npm install + +# Copy the rest of the application to the working directory +COPY . . + +# Expose the port the app will run on +EXPOSE 4000 + +# Command to run the applicaiton +CMD ["npm", "run", "server"] \ No newline at end of file diff --git a/README.md b/README.md index 00db566..699098c 100644 --- a/README.md +++ b/README.md @@ -1 +1,25 @@ # server + +## Running with Docker +1. **Build the Dokcker Image**: Build the Docker image locally. + +```bash +docker build -t notify-med-server:latest . +``` + +2. **Run the Docker Container**: +After building th image, you can run the application in a container . + +```bash +docker run \ + -p 4000:4000 \ + -e MONGO_URI=mongodb://your-database-ip/NotifyMEd \ + -d \ + server-app:latest +``` + +3. Access the application on `http://localhost:4000`. + +## Environmental variables + +You can also pass other environmenetal variabbles usinf the `-e` flag with docker run. For example, to set `JWT_SECRET`, you can add `-e JWT_SECRET=your_secret_here` to the `docker run` command.