Skip to content

Commit

Permalink
Merge pull request #12 from Wilcolab/copilot6
Browse files Browse the repository at this point in the history
feat: add simple Express server with Docker support
  • Loading branch information
peterszekeli authored Oct 30, 2024
2 parents 93f8938 + 4e085e5 commit 39b0e68
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ services:
- 8000:8000
volumes:
- ./python-server/src:/app/src

node-server:
build:
context: ./simple-express-server
dockerfile: Dockerfile
ports:
- 8001:8001
volumes:
- ./simple-express-server/src:/app/src
9 changes: 9 additions & 0 deletions simple-express-server/Dockerfile
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" ]
60 changes: 60 additions & 0 deletions simple-express-server/README.md
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`.
16 changes: 16 additions & 0 deletions simple-express-server/package.json
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"
}
9 changes: 9 additions & 0 deletions simple-express-server/src/server.js
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}`);
});

0 comments on commit 39b0e68

Please sign in to comment.