Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ RUN cp target/release/pg-pkg /usr/local/cargo/bin/pg-pkg
FROM debian:trixie-slim
RUN groupadd -r nonroot \
&& useradd -r -g nonroot nonroot
RUN apt-get update && apt-get --no-install-recommends install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get --no-install-recommends install -y ca-certificates libssl3 curl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/pg-pkg /usr/local/bin/pg-pkg
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN mkdir -p /app && chown nonroot:nonroot /app
WORKDIR /app
USER nonroot

EXPOSE 8087

CMD ["/bin/sh", "-c", "/usr/local/bin/pg-pkg server ${IRMA_TOKEN:+-t $IRMA_TOKEN} -i ${IRMA_SERVER}"]
ENTRYPOINT ["/entrypoint.sh"]
30 changes: 30 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -e

KEYS_DIR=/tmp/keys

mkdir -p "$KEYS_DIR"

if [ -n "$PKG_IBE_SECRET" ] && [ -n "$PKG_IBE_PUBLIC" ] && [ -n "$PKG_IBS_SECRET" ] && [ -n "$PKG_IBS_PUBLIC" ]; then
echo "Loading keys from environment variables..."
printf '%s' "$PKG_IBE_SECRET" | base64 -d > "$KEYS_DIR/pkg_ibe.sec"
printf '%s' "$PKG_IBE_PUBLIC" | base64 -d > "$KEYS_DIR/pkg_ibe.pub"
printf '%s' "$PKG_IBS_SECRET" | base64 -d > "$KEYS_DIR/pkg_ibs.sec"
printf '%s' "$PKG_IBS_PUBLIC" | base64 -d > "$KEYS_DIR/pkg_ibs.pub"
chmod 600 "$KEYS_DIR/pkg_ibe.sec" "$KEYS_DIR/pkg_ibs.sec"
else
echo "No key environment variables set. Generating new keys..."
/usr/local/bin/pg-pkg gen \
--ibe-secret-path "$KEYS_DIR/pkg_ibe.sec" \
--ibe-public-path "$KEYS_DIR/pkg_ibe.pub" \
--ibs-secret-path "$KEYS_DIR/pkg_ibs.sec" \
--ibs-public-path "$KEYS_DIR/pkg_ibs.pub"
fi

exec /usr/local/bin/pg-pkg server \
${IRMA_TOKEN:+-t "$IRMA_TOKEN"} \
-i "${IRMA_SERVER:-https://is.yivi.app}" \
--ibe-secret-path "$KEYS_DIR/pkg_ibe.sec" \
--ibe-public-path "$KEYS_DIR/pkg_ibe.pub" \
--ibs-secret-path "$KEYS_DIR/pkg_ibs.sec" \
--ibs-public-path "$KEYS_DIR/pkg_ibs.pub"
Loading