Skip to content

Commit 82a85f1

Browse files
authored
Merge pull request #2386 from chaitanyarahalkar/add/gh-action
feat: add the GitHub action to create a Docker image and push to Docker Registry
2 parents 1233a2e + 4ef554a commit 82a85f1

File tree

2 files changed

+78
-11
lines changed

2 files changed

+78
-11
lines changed

.github/workflows/docker-build.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Push Docker Images
2+
on:
3+
schedule:
4+
- cron: '0 0 1 * *' # Run monthly on the 1st
5+
workflow_dispatch: # Allow manual triggers
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
strategy:
16+
matrix:
17+
variant:
18+
- name: regular
19+
file: Dockerfile
20+
suffix: ''
21+
- name: alpine
22+
file: Dockerfile-alpine
23+
suffix: '-alpine'
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
30+
31+
- name: Log in to the Container registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata for Docker
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=raw,value=latest${{ matrix.variant.suffix }}
45+
type=raw,value={{date 'YYYYMMDD'}}${{ matrix.variant.suffix }}
46+
47+
- name: Build and push image
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
file: ./${{ matrix.variant.file }}
52+
push: true
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}

README.md

+24-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ Keep track of development news:
2020

2121
Unless you wish to contribute to the project, we recommend using the hosted version at [devdocs.io](https://devdocs.io). It's up-to-date and works offline out-of-the-box.
2222

23+
### Using Docker (Recommended)
24+
25+
The easiest way to run DevDocs locally is using Docker:
26+
27+
```sh
28+
docker run --name devdocs -d -p 9292:9292 ghcr.io/freecodcamp/devdocs:latest
29+
```
30+
31+
This will start DevDocs at [localhost:9292](http://localhost:9292). We provide both regular and Alpine-based images:
32+
- `ghcr.io/freecodcamp/devdocs:latest` - Standard image
33+
- `ghcr.io/freecodcamp/devdocs:latest-alpine` - Alpine-based (smaller size)
34+
35+
Images are automatically built and updated monthly with the latest documentation.
36+
37+
Alternatively, you can build the image yourself:
38+
39+
```sh
40+
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
41+
docker build -t devdocs .
42+
docker run --name devdocs -d -p 9292:9292 devdocs
43+
```
44+
45+
### Manual Installation
46+
2347
DevDocs is made of two pieces: a Ruby scraper that generates the documentation and metadata, and a JavaScript app powered by a small Sinatra app.
2448

2549
DevDocs requires Ruby 3.3.0 (defined in [`Gemfile`](./Gemfile)), libcurl, and a JavaScript runtime supported by [ExecJS](https://github.com/rails/execjs#readme) (included in OS X and Windows; [Node.js](https://nodejs.org/en/) on Linux). Once you have these installed, run the following commands:
@@ -38,17 +62,6 @@ The `thor docs:download` command is used to download pre-generated documentation
3862

3963
**Note:** there is currently no update mechanism other than `git pull origin main` to update the code and `thor docs:download --installed` to download the latest version of the docs. To stay informed about new releases, be sure to [watch](https://github.com/freeCodeCamp/devdocs/subscription) this repository.
4064

41-
Alternatively, DevDocs may be started as a Docker container:
42-
43-
```sh
44-
# First, build the image
45-
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
46-
docker build -t thibaut/devdocs .
47-
48-
# Finally, start a DevDocs container (access http://localhost:9292)
49-
docker run --name devdocs -d -p 9292:9292 thibaut/devdocs
50-
```
51-
5265
## Vision
5366

5467
DevDocs aims to make reading and searching reference documentation fast, easy and enjoyable.

0 commit comments

Comments
 (0)