1- FROM clux/muslrust:stable as chef
2- WORKDIR /siwe-oidc
3- RUN cargo install cargo-chef
4-
5- FROM chef as dep_planner
6- COPY ./src/ ./src/
7- COPY ./Cargo.lock ./
8- COPY ./Cargo.toml ./
9- COPY ./siwe-oidc.toml ./
10- RUN cargo chef prepare --recipe-path recipe.json
11-
12- FROM chef as dep_cacher
13- COPY --from=dep_planner /siwe-oidc/recipe.json recipe.json
14- RUN cargo chef cook --release --recipe-path recipe.json
1+ FROM node:20-alpine as builder
152
16- FROM node:18.20.0-alpine3.18 as node_builder
3+ WORKDIR /siwe-oidc
174
185# Reference https://github.com/mhart/alpine-node/issues/27#issuecomment-880663905
196RUN apk add --no-cache --virtual .build-deps alpine-sdk python3
@@ -24,27 +11,45 @@ ARG WALLET_CONNECT_ID
2411ENV INFURA_ID=${INFURA_ID}
2512ENV WALLET_CONNECT_ID=${WALLET_CONNECT_ID}
2613
14+ # Copy static files and UI
2715ADD --chown=node:node ./static /siwe-oidc/static
2816ADD --chown=node:node ./js/ui /siwe-oidc/js/ui
2917WORKDIR /siwe-oidc/js/ui
3018RUN yarn
3119RUN yarn build
3220
33- FROM chef as builder
34- COPY --from=dep_cacher /siwe-oidc/target/ ./target/
35- COPY --from=dep_cacher $CARGO_HOME $CARGO_HOME
36- COPY --from=dep_planner /siwe-oidc/ ./
37- RUN cargo build --release
21+ # Build the Node.js application
22+ FROM node:20-alpine
3823
39- FROM alpine
40- COPY --from=builder /siwe-oidc/target/x86_64-unknown-linux-musl/release/siwe-oidc /usr/local/bin/
4124WORKDIR /siwe-oidc
42- RUN mkdir -p ./static
43- COPY --from=node_builder /siwe-oidc/static/ ./static/
44- COPY --from=builder /siwe-oidc/siwe-oidc.toml ./
25+ COPY ./siwe-oidc-js ./siwe-oidc-js
26+ WORKDIR /siwe-oidc/siwe-oidc-js
27+
28+ # Install dependencies
29+ RUN npm install
30+
31+ # Copy application source
32+ COPY . .
33+
34+ # Copy static files from builder
35+ COPY --from=builder /siwe-oidc/static/ ./static/
36+
37+ # Generate RSA key if not provided
38+ RUN if [ -z "$RSA_PEM" ]; then \
39+ apk add --no-cache openssl && \
40+ openssl genrsa -out /tmp/private.pem 2048 && \
41+ export RSA_PEM=$(cat /tmp/private.pem) && \
42+ rm /tmp/private.pem; \
43+ fi
44+
45+ # Set environment variables
4546ENV SIWEOIDC_ADDRESS="0.0.0.0"
47+ # Expose port
4648EXPOSE 8000
47- ENTRYPOINT ["siwe-oidc" ]
49+ # Start the application
50+ CMD ["npm" , "start" ]
51+
52+ # Labels
4853LABEL org.opencontainers.image.source https://github.com/spruceid/siwe-oidc
4954LABEL org.opencontainers.image.description "OpenID Connect Identity Provider for Sign-In with Ethereum"
5055LABEL org.opencontainers.image.licenses "MIT OR Apache-2.0"
0 commit comments