Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Caddyfile.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
readme-stats.example.com {
reverse_proxy readme_stats:9000
}

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts-alpine

# setup folder within the docker container with this app's files
WORKDIR /app
COPY . .

# add express.js as dependency and download node modules
RUN npm install express.js

# start the app, on the supplied port
EXPOSE $port
CMD [ "node", "express.js" ]

22 changes: 22 additions & 0 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
readme_stats:
build: .
container_name: readme_stats
restart: unless-stopped
env_file:
- .env
expose:
- $port

caddy:
image: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
depends_on:
- readme_stats
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro

5 changes: 5 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# github token
PAT_1=<YOUR_GITHUB_TOKEN>
# port to listen on
port=9000

10 changes: 9 additions & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ router.get("/gist", gistCard);
app.use("/api", router);

const port = process.env.PORT || process.env.port || 9000;
app.listen(port, "0.0.0.0", () => {
const server = app.listen(port, "0.0.0.0", () => {
console.log(`Server running on port ${port}`);
});

/* stop gracefully when requested */
process.on("SIGTERM", () => {
console.log("stopping, received SIGTERM signal");
server.close(() => {
process.exit();
});
});
35 changes: 35 additions & 0 deletions readme-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Get dynamically generated GitHub stats on your READMEs, with the ease of docker!

Fork of [https://github.com/anuraghazra/github-readme-stats](https://github.com/anuraghazra/github-readme-stats), gently wrapped in docker.

**Steps to setup:**
* clone this repo into a folder.
* copy docker-compose.yml.example to docker-compose.yml.
* copy env.example to .env and update.
* copy Caddyfile.example to Caddyfile and update.
* and start with `docker compose up -d`.

docker-compose.yml.example has a very simple Caddy reverse proxy, for automatic https.

Files have example in their name, so that when you update, your local settings won't be overridden.

```
git clone https://code.digitaladapt.com/andrew/github-readme-stats.git
cd github-readme-stats
cp docker-compose.yml.example docker-compose.yml
cp env.example .env
vim .env
# add your github token

cp Caddyfile.example Caddyfile
vim Caddyfile
# configure your domain

docker compose up -d
```

You might ask, why should I trust your docker image?

The answer is, you don't have to, there isn't an image,
just a few commands in the Dockerfile, which you can and should look at.