Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Juansecu committed May 13, 2024
0 parents commit c9ad1b5
Show file tree
Hide file tree
Showing 9 changed files with 1,487 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80

[*.md]
indent_size = 4
71 changes: 71 additions & 0 deletions .github/workflows/deliver-application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Deliver Application

on:
push:
tags:
- 'v*.*.*'
workflow_run:
types:
- completed
workflows:
- Check Linter Errors

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
strategy:
matrix:
node-version: [ 20.x ]
pnpm-version: [ 8.x ]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- run: mkdir build
- run: mv src/ build
- name: Zip application
uses: vimtor/action-zip@v1.1
with:
dest: letsencrypt-acme-challenge-server-${{ github.ref_name }}.zip
files: build package.json package-lock.yaml
- name: Release application
uses: softprops/action-gh-release@v1
with:
body: Version ${{ github.ref_name }} of the application
body_path: ./CHANGELOG.md
files: |
letsencrypt-acme-challenge-server-${{ github.ref_name }}.zip
fail_on_unmatched_files: true
generate_release_notes: true
draft: false
prerelease: false

push-docker-image:
name: Push Docker Image
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
strategy:
matrix:
docker-repository: [ juansecu/letsencrypt-acme-challenge-server ]
platforms:
- linux/amd64
- linux/arm64
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Log in to registry
uses: docker/login-action@v3
with:
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
- name: Build and push the Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platforms }}
push: true
tags: ${{ matrix.docker-repository }}:${{ github.ref_name }},${{ matrix.docker-repository }}:latest
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dependency directories
node_modules/

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# Editor directories and files
.idea/
.vscode/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Optional eslint cache
.eslintcache

# Optional npm cache directory
.npm

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Serverless directories
.serverless/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

WORKDIR /app

COPY package.json package-lock.json ./
COPY src ./src

RUN chown -R node /app
USER node

RUN npm install --production

CMD ["npm", "start"]
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Let's Encrypt ACME Challenge Server

This is a simple server that can be used
to serve ACME challenge requests for Let's Encrypt.

## Requirements

- **Node.js -** Version 20
- **Environment variables:**

- `LETSENCRYPT_CHALLENGE` - The challenge string that Let's Encrypt will request.

## Running

### Using Docker (Recommended)

In order to run the application using [Docker](https://www.docker.com/),
you must have Docker installed on your machine.

For running the application with Docker,
you will need to map port `80` to your host machine.

#### Docker CLI

- **Windows**

```shell
> docker run -dp 8080:8080 \
-e LETSENCRYPT_CHALLENGE="<Let's Encrypt challenge string>" \
--name <container-name> \
juansecu/letsencrypt-acme-challenge-server:v<version number>
```

- **MacOS/Linux**

```shell
$ docker run -dp 8080:8080 \
-e LETSENCRYPT_CHALLENGE="<Let's Encrypt challenge string>" \
--name <container-name> \
juansecu/letsencrypt-acme-challenge-server:v<version number>
```

#### Docker Compose

For running the application with Docker Compose, you can use
the [Docker Compose file](https://github.com/Juansecu/letsencrypt-acme-challenge-server/blob/main/docker-compose.yml)
provided in this repository for development and production,
but for production, you will also need to
remove the `build` property from the `http-server` service,
change the `image` property to `juansecu/letsencrypt-acme-challenge-server:v<version number>`.

You can run the application using the following command:

- **Docker Compose v1**

```shell
$ docker-compose up -d
```

- **Docker Compose v2**

```shell
$ docker compose up -d
```

### Using Node.js

For running the application with Node.js,
you will need to set the necessary environment variables
and follow the instructions below.

#### For Development

In order to run the application for development,
you will need to clone this repository
and run it using the following commands:

- **Windows**

```shell
# --- INSTALLING DEPENDENCIES ---
> npm install
# --- RUNNING ---
> npm run dev
```

- **MacOS/Linux**

```shell
# --- INSTALLING DEPENDENCIES ---
$ npm install
# --- RUNNING ---
$ npm run dev
```

#### For Production

In order to run the application for production,
you will only need to download the latest release
from the [releases page](https://github.com/Juansecu/letsencrypt-acme-challenge-server/releases),
set the necessary environment variables
and run the application using the following commands:

- **Windows**

```shell
# --- INSTALLING DEPENDENCIES ---
> npm install --production
# --- RUNNING ---
> npm start
```

- **MacOS/Linux**

```shell
# --- INSTALLING DEPENDENCIES ---
$ npm install --production
# --- RUNNING ---
$ npm start
```
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.9'

services:
http-server:
image: letsencrypt-acme-challenge-server
container_name: letsencrypt-acme-challenge-server
build:
context: .
dockerfile: Dockerfile
environment:
LETSENCRYPT_CHALLENGE: ${LETSENCRYPT_CHALLENGE}
ports:
- '80:80'
Loading

0 comments on commit c9ad1b5

Please sign in to comment.