Skip to content

Commit

Permalink
Merge pull request #2386 from chaitanyarahalkar/add/gh-action
Browse files Browse the repository at this point in the history
feat: add the GitHub action to create a Docker image and push to Docker Registry
  • Loading branch information
simon04 authored Dec 17, 2024
2 parents 1233a2e + 4ef554a commit 82a85f1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Push Docker Images
on:
schedule:
- cron: '0 0 1 * *' # Run monthly on the 1st
workflow_dispatch: # Allow manual triggers
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
variant:
- name: regular
file: Dockerfile
suffix: ''
- name: alpine
file: Dockerfile-alpine
suffix: '-alpine'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest${{ matrix.variant.suffix }}
type=raw,value={{date 'YYYYMMDD'}}${{ matrix.variant.suffix }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.variant.file }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ Keep track of development news:

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.

### Using Docker (Recommended)

The easiest way to run DevDocs locally is using Docker:

```sh
docker run --name devdocs -d -p 9292:9292 ghcr.io/freecodcamp/devdocs:latest
```

This will start DevDocs at [localhost:9292](http://localhost:9292). We provide both regular and Alpine-based images:
- `ghcr.io/freecodcamp/devdocs:latest` - Standard image
- `ghcr.io/freecodcamp/devdocs:latest-alpine` - Alpine-based (smaller size)

Images are automatically built and updated monthly with the latest documentation.

Alternatively, you can build the image yourself:

```sh
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
docker build -t devdocs .
docker run --name devdocs -d -p 9292:9292 devdocs
```

### Manual Installation

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.

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:
Expand All @@ -38,17 +62,6 @@ The `thor docs:download` command is used to download pre-generated documentation

**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.

Alternatively, DevDocs may be started as a Docker container:

```sh
# First, build the image
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
docker build -t thibaut/devdocs .

# Finally, start a DevDocs container (access http://localhost:9292)
docker run --name devdocs -d -p 9292:9292 thibaut/devdocs
```

## Vision

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

0 comments on commit 82a85f1

Please sign in to comment.