diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..febbb5c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/node_modules +/build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d032549 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:14.18-alpine AS BUILD_IMAGE +RUN apk add --no-cache nodejs npm +WORKDIR /ms-webserver +COPY ["package.json", "./"] +RUN npm install +COPY . . +RUN npm run build + +FROM node:14.18-alpine +WORKDIR /app +COPY --from=BUILD_IMAGE /ms-webserver /app/ +EXPOSE 8078 +ENTRYPOINT [ "npm", "run" ] +CMD [ "start" ] \ No newline at end of file diff --git a/README.md b/README.md index 79ad805..22201c4 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,40 @@ Read further to know how **you** can start contributing to MS Club! ## Quick Links - [Tech Stack](#tech-stack) - [How to contribute](#how-to-contribute) -- [Learning Resources](#resources) +- [Learning Resources](#how-can-i-get-start) +- [About Docker Image](#about-docker-image) -## [Tech Stack](#Tech-stack) +## [Tech Stack](#Tech-stack) :electron: ![banner-whitegb-spacing-10x(2)](https://firebasestorage.googleapis.com/v0/b/msclubofsliit-v2.appspot.com/o/tech_stack_logo.png?alt=media&token=74635794-1141-411c-8b82-5e90f6113aae) -## [How to contribute](#how-to) +## [How to contribute](#how-to) :octocat: 1. Fork the repo on GitHub. 2. Clone the project to your own machine.
-```git clone https://github.com//msclubwebsite.git``` +``` +git clone https://github.com//msclubwebsite.git +``` 3. Create a branch using the git checkout command. Branch name prefix should be one of these.
`feature/`
`fix/`
-```git checkout -b ``` +``` +git checkout -b +``` 4. Stage your changes and commit with a meaningful commit message. **First letter of the commit should be capital**
-```git add .```
-```git commit -m "" ``` +``` +git add . +``` +``` +git commit -m "" +``` 5. Push your work back up to your fork.
-```git push origin ``` +``` +git push origin +``` 6. Submit a Pull request so that we can review your changes. [Learn about creating a pull request.](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) -## [How can I get start](#resources) +## [How can I get start](#resources) :thinking: We got your back. Here are some **FREE** resources for you to strengthen your web development skills and start firing some commits. **TypeScript** @@ -37,4 +48,41 @@ We got your back. Here are some **FREE** resources for you to strengthen your we **Node JS / Express** - [Node JS 14.x Official Documentaion](https://nodejs.org/docs/latest-v14.x/api/) -- [Express Official Documentation](https://expressjs.com/) \ No newline at end of file +- [Express Official Documentation](https://expressjs.com/) + +## [About Docker Image](#about-docker-image) :whale: +We use Docker image to deploy this API application to the server. You can build and run the docker container in your local machine. Follow below steps to build and run the Docker container.
+:memo: In order to build and run the Docker container, you must have Docker install on you computer.
+ +1. :building_construction: Build the Docker image. +``` +docker build -t ghcr.io/ms-club-sliit/msclubwebserver:v1.0.0 . +``` +2. :heavy_check_mark: Check the build Docker images. +``` +docker image ls +``` +3. :package: Run the Docker container. After run this command the container will start running.
+`docker run -p : -d --name "":`
+**`-d`** - Run in ditach mode
+**`-p`** - Port mapping between Docker container and application + +``` +docker run -p 9096:8078 -d --name "mswebserver" ghcr.io/ms-club-sliit/msclubwebserver:v1.0.0 +``` +4. :earth_asia: Open your web browser and paste below URL +``` +http://localhost:9096 +``` +5. :eyes: View the running container +``` +docker ps +``` +6. :stop_sign: Stop the running container +``` +docker stop mswebserver +``` +7. :coffin: Remove the Docker container +``` +docker rm mswebserver +``` \ No newline at end of file diff --git a/package.json b/package.json index 4c1eb62..965bf1d 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "MS Club Web Site Server", "main": "app.js", "scripts": { + "start": "env-cmd -f ./src/config/.env.production node build/app.js", "dev:server": "env-cmd -f ./src/config/.env.development nodemon src/app.ts", "prod:server": "env-cmd -f ./src/config/.env.production nodemon src/app.ts", "build": "tsc -p ."