Skip to content

Commit

Permalink
Dockerfile: Add Dockerfile and respective workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Sando authored and FriedrichAltheide committed Oct 3, 2023
1 parent 6bc4023 commit f3fb40f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/ctr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build & publish fpush ctr image

on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

env:
REGISTRY: ghcr.io

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
load: true
tags: ${{ steps.meta.outputs.tags }}

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

## currently not pushing the image to the github registry.

# - name: Build & push image
# uses: docker/build-push-action@v3
# if: github.event_name == 'push'
# with:
# context: .
# file: docker/Dockerfile
# labels: ${{ steps.meta.outputs.labels }}
# platforms: linux/amd64
# push: true
# tags: ${{ steps.meta.outputs.tags }}
21 changes: 21 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### alternative tag is e.g. '1.72.0'
ARG RUST_VSN='stable'

##### Build
FROM docker.io/clux/muslrust:${RUST_VSN} as builder

COPY / ./
RUN cargo build --release

RUN mkdir -p /rootfs/etc/fpush \
&& mv $(find target/ -name fpush -type f -executable) /rootfs/fpush \
&& touch /rootfs/etc/fpush/settings.json

##### Runtime
FROM gcr.io/distroless/static-debian12:nonroot AS prod

COPY --from=builder /rootfs /

ENV RUST_LOG=info

ENTRYPOINT ["/fpush","/etc/fpush/settings.json"]
24 changes: 24 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dockerfile for fpush

This folder holds an example Dockerfile.

To build the image, run the following command from the root of this repository:

```bash
docker build -t localhost/fpush:latest -f docker/Dockerfile .
```

Run the image with:

```bash
docker run --init -d \
--name fpush \
-v /path/to/settings.json:/etc/fpush/settings.json \
-v /path/to/apple.p12:/path/to/apple.p12 \
-v /path/to/google.json:/path/to/google.json \
-e RUST_LOG=info \
localhost/fpush:latest
```

Note: Apple's p12 and/or Google's json file need to be mounted into the
container as you can see in the example above.

0 comments on commit f3fb40f

Please sign in to comment.