Skip to content

Commit

Permalink
feat: add docker support (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
septs authored Jun 17, 2024
1 parent 13090b1 commit 76671b8
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 1 deletion.
81 changes: 81 additions & 0 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Docker image

on:
pull_request:
branches: [main]
push:
branches: [main]
tags: [v*]
paths-ignore:
- "**/*.md"
- LICENSE
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: |
linux/amd64
linux/arm64
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=tag
- name: Build and Push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
target: production
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: ${{ steps.qemu.outputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
- name: Delete Untagged Packages
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ github.token }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lpac"]
path = lpac
url = https://github.com/estkme-group/lpac.git
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Stage 1: Build Stage
FROM alpine:3.20 AS build
WORKDIR /srv/

RUN apk add --no-cache bash git gcc cmake make musl-dev curl-dev

COPY . .

RUN ./scripts/build.sh

# Stage 2: Production Stage
FROM alpine:3.20 AS production
WORKDIR /app/

RUN apk add --no-cache libcurl php83

COPY --from=build /srv/lpac/output/ /app/

CMD ["php", "./rlpa-server.php"]

EXPOSE 1888
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Remote LPA Server

Technical details see [Protocol Design](docs/protocol-design.md)
Technical details, see [Protocol Design](docs/protocol-design.md)

## Usage on Docker

You can also run the server using [Docker](https://docs.docker.com/engine/install/).
You can use the following command to run the server:

```bash
docker run --detach --name rlpa-server --publish 1888:1888 estkme/rlpa-server:latest
# or use the GitHub Container Registry
docker run --detach --name rlpa-server --publish 1888:1888 ghcr.io/estkme-group/rlpa-server:latest
```

## Community implementation

Expand Down
1 change: 1 addition & 0 deletions lpac
Submodule lpac added at dace65
9 changes: 9 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -xeuo pipefail

cd lpac || exit 1

cmake . -DLPAC_WITH_APDU_PCSC=off -DLPAC_WITH_APDU_AT=off
make -j

cp ../rlpa-server.php ./output

0 comments on commit 76671b8

Please sign in to comment.