https://github.com/pradumnasaraf/bun-docker
About A simple HTTP server implemented in JavaScript uses Bun as runtime. This is for Docker's official Bun Language Guide. Resources
https://github.com/pradumnasaraf/bun-docker
bun docker docker-compose
Last synced: about 1 month ago
JSON representation
About A simple HTTP server implemented in JavaScript uses Bun as runtime. This is for Docker's official Bun Language Guide. Resources
- Host: GitHub
- URL: https://github.com/pradumnasaraf/bun-docker
- Owner: Pradumnasaraf
- License: mit
- Created: 2024-09-06T06:30:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-06T08:26:53.000Z (about 1 year ago)
- Last Synced: 2025-08-29T09:23:13.703Z (about 1 month ago)
- Topics: bun, docker, docker-compose
- Language: JavaScript
- Homepage: https://docs.docker.com/guides/bun
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A simple HTTP server build with JavaScript and using Bun as runtime to serve a simple JSON response. This is for Docker's [Bun Language Guide](https://docs.docker.com/language/bun/).
## API
The server only supports the HTTP GET method at the moment. When a GET request is received, the server responds with a JSON object:
```json
{
"message": "OK"
}
```## Running with Docker Compose
Below is the [Dockerfile](Dockerfile) for the our server:
```Dockerfile
# Use the official Bun image as the base image
FROM oven/bun:latest# Set the working directory in the container
WORKDIR /app# Copy the current directory contents into the container at /app
COPY . .# Expose the port on which the API will listen
EXPOSE 3000# Run the server when the container launches
CMD ["bun", "server.js"]
```To run this application using Docker Compose, you'll need to create a `compose.yml` file.
Here's the `compose.yml` file:
```yaml
services:
server:
image: bun-api
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
```To build and run the Docker image using Docker Compose, use the following command:
```bash
docker compose up
```This will build the Docker image and then run it, mapping the container's port 3000 to port 3000 on the host machine. You can then access the API by visiting `http://localhost:3000` in your web browser.
## Contributing
Any feedback and contributions are welcome! Please open an issue before submitting a pull request.
## License
[MIT License](LICENSE)