Skip to content

Commit 62d5735

Browse files
Merge pull request #3 from zopdev/add-readme
Add reame
2 parents 6d7cf4e + 48f8d26 commit 62d5735

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Static Server
2+
3+
A simple and efficient solution for serving static files. This server can be easily deployed via Docker, and it's optimized for serving static websites.
4+
5+
## Features
6+
7+
- **Easy to use**: Just place your static files in the `website` directory, and the server takes care of the rest.
8+
- **Dockerized**: Easily deployable as a Docker container.
9+
- **Lightweight**: Minimal dependencies for optimal performance.
10+
- **Configurable**: You can easily configure the server or extend it based on your needs.
11+
12+
## Requirements
13+
14+
To use this static server, you need the following:
15+
- Docker installed on your system.
16+
17+
## Usage
18+
19+
### 1. Build a Docker image
20+
21+
To deploy the server, you need to build a Docker image using the provided `Dockerfile`.
22+
23+
#### Example `Dockerfile`
24+
25+
```dockerfile
26+
# Use the official static-server image as the base image
27+
# This will pull the latest prebuilt version of the static-server to run your static website
28+
FROM zopdev/static-server:latest
29+
30+
# Copy static files into the container
31+
# The 'COPY' directive moves your static files (in this case, located at '/app/out') into the '/website' directory
32+
# which is where the static server expects to find the files to serve
33+
COPY /app/out /website
34+
35+
# Expose the port on which the server will run
36+
# By default, the server listens on port 8000, so we expose that port to allow access from outside the container
37+
EXPOSE 8000
38+
39+
# Define the command to run the server
40+
# The static server is started with the '/main' binary included in the image, which will start serving
41+
# the files from the '/website' directory on port 8000
42+
CMD ["/main"]
43+
```
44+
45+
### 2. Build the Docker image
46+
47+
Navigate to your project directory and run the following command to build the Docker image:
48+
49+
```bash
50+
docker build -t static-server .
51+
```
52+
53+
This command:
54+
- Uses the `Dockerfile` in the current directory (`.`) to build an image.
55+
- Tags the image with the name `static-server` (`-t static-server`).
56+
57+
### 3. Run the Docker container
58+
59+
Once the image is built, run the container using the following command:
60+
61+
```bash
62+
docker run -d -p 8000:8000 static-server
63+
```
64+
65+
This command:
66+
- Runs the container in detached mode (`-d`).
67+
- Maps port 8000 on your host machine to port 8000 inside the container (`-p 8000:8000`), so you can access the static files via `http://localhost:8000`.
68+
69+
### 4. Access your static website
70+
71+
Once the container is running, you can visit your website at:
72+
73+
```
74+
http://localhost:8000
75+
```
76+
77+
Your static files will be served, and the root (`/`) will typically display your `index.html` (if present).
78+
79+
## Notes
80+
81+
- The static server is designed to handle a large number of requests efficiently. However, if you have special requirements (such as caching or routing), you may need to customize the server or use additional reverse proxies (like Nginx).
82+
- The server serves all files in the `website` directory, so make sure to avoid any sensitive files or configuration details in that directory.
83+
84+
## License
85+
86+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)