generated from trywilco/Anythink-Market-Public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Wilcolab/copilot6
feat: add simple Express server with Docker support
- Loading branch information
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:14 | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json /app | ||
RUN yarn install | ||
EXPOSE 8001 | ||
|
||
CMD [ "yarn", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Simple Express Server | ||
|
||
This project is a simple Express server that listens on port 8001. It is designed to demonstrate a basic setup with Docker and nodemon for automatic reloading during development. | ||
|
||
## Project Structure | ||
|
||
``` | ||
simple-express-server | ||
├── src | ||
│ └── server.js # Entry point of the application | ||
├── Dockerfile # Docker configuration file | ||
├── package.json # npm configuration file | ||
├── yarn.lock # Dependency lock file | ||
└── README.md # Project documentation | ||
``` | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- Node.js | ||
- Yarn | ||
|
||
### Installation | ||
|
||
1. Clone the repository: | ||
``` | ||
git clone <repository-url> | ||
cd simple-express-server | ||
``` | ||
|
||
2. Install dependencies: | ||
``` | ||
yarn install | ||
``` | ||
|
||
### Running the Server | ||
|
||
To start the server with nodemon, run: | ||
``` | ||
yarn start | ||
``` | ||
|
||
The server will listen on port 8001. | ||
|
||
### Building the Docker Image | ||
|
||
To build the Docker image, run: | ||
``` | ||
docker build -t simple-express-server . | ||
``` | ||
|
||
### Running the Docker Container | ||
|
||
To run the Docker container, use: | ||
``` | ||
docker run -p 8001:8001 simple-express-server | ||
``` | ||
|
||
The server will be accessible at `http://localhost:8001`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "simple-express-server", | ||
"version": "1.0.0", | ||
"main": "src/server.js", | ||
"scripts": { | ||
"start": "nodemon src/server.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^2.0.7" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// src/server.js | ||
const express = require('express'); | ||
const app = express(); | ||
|
||
const PORT = 8001; | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Server is listening on port ${PORT}`); | ||
}); |