Skip to content

Commit dcfe67a

Browse files
authored
Updated deps and made workflow for delivery (#26)
* Updated Rust dependencies * testing workflow * Update delivery.yml * Update delivery.yml * made working dockerfile not doing anything in the compose anymore... * backup edge tag * Update delivery.yml * Delete build.yml
1 parent 7197a5c commit dcfe67a

11 files changed

Lines changed: 62935 additions & 31073 deletions

File tree

.github/workflows/delivery.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Delivery
2+
3+
on:
4+
push:
5+
branches: [main]
6+
release:
7+
# Note: a current limitation is that when a release is edited after publication, then the Docker tags are not automatically updated.
8+
types: [published]
9+
schedule:
10+
# Run every monday on 9:00 in the morning (UTC).
11+
- cron: '0 9 * * 0'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
packages: write
17+
security-events: write
18+
19+
jobs:
20+
publish-docker-image:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Check whether this event is the HEAD of main
27+
continue-on-error: true
28+
id: is-head-main
29+
run: git rev-parse HEAD | grep -x ${{ github.sha }}
30+
shell: bash
31+
32+
- name: Docker meta
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ghcr.io/${{ github.repository }}
37+
tags: |
38+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
39+
type=edge,enable=${{ steps.is-head-main.outcome == 'success' }}
40+
type=ref,event=branch,enable=${{ github.event_name == 'workflow_dispatch' }}
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Build container and export to local Docker
53+
uses: docker/build-push-action@v5
54+
with:
55+
context: .
56+
file: backend.Dockerfile
57+
load: true
58+
tags: local/postguard-backend:scan
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
62+
- name: Scan Image
63+
uses: anchore/scan-action@v4
64+
id: scan
65+
with:
66+
image: local/postguard-backend:scan
67+
only-fixed: true
68+
fail-build: true
69+
severity-cutoff: critical
70+
output-format: sarif
71+
72+
- name: Upload Anchore scan SARIF report
73+
uses: github/codeql-action/upload-sarif@v4
74+
if: ${{ !cancelled() }}
75+
with:
76+
sarif_file: ${{ steps.scan.outputs.sarif }}
77+
78+
- name: Push image to GitHub Container Registry
79+
uses: docker/build-push-action@v5
80+
if: ${{ github.event_name == 'release' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
81+
with:
82+
context: .
83+
file: backend.Dockerfile
84+
push: true
85+
tags: ${{ steps.meta.outputs.tags || 'edge' }}
86+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ dist/
22
data/
33
irma/
44
target/
5+
6+
.idea
7+
.vscode

backend.Dockerfile

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
FROM debian:buster-slim
2-
RUN apt-get update && \
3-
apt-get install -y libssl-dev && \
4-
rm -rf /var/lib/apt/lists/*
1+
FROM rust:1.91.0-slim-trixie AS builder
2+
3+
ENV ROCKET_PROFILE=release
4+
5+
WORKDIR /app
6+
7+
COPY cryptify-back-end/src ./src
8+
COPY cryptify-back-end/templates ./templates
9+
COPY cryptify-back-end/Cargo.toml .
10+
COPY cryptify-back-end/Cargo.lock .
11+
12+
RUN apt-get update \
13+
&& apt-get --no-install-recommends install -y libssl-dev pkg-config \
14+
&& rm -rf /var/lib/apt/lists/* \
15+
&& cargo build --release \
16+
&& cp ./target/release/cryptify-backend /usr/local/bin/cryptify-backend
17+
18+
19+
FROM debian:trixie-slim
20+
ENV ROCKET_CONFIG=config.toml
21+
22+
RUN groupadd -r nonroot \
23+
&& useradd -r -g nonroot nonroot \
24+
&& apt-get update \
25+
&& apt-get --no-install-recommends install -y ca-certificates libssl3 \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
COPY --from=builder /usr/local/bin/cryptify-backend /usr/local/bin/cryptify-backend
29+
RUN mkdir -p /app && chown nonroot:nonroot /app
30+
31+
WORKDIR /app
32+
USER nonroot
33+
34+
RUN mkdir -p /tmp/data
35+
36+
CMD ["/bin/sh", "-c", "/usr/local/bin/cryptify-backend"]

0 commit comments

Comments
 (0)