Skip to content

Commit 0c2629b

Browse files
committed
feat: add build Dockerfiles and entrypoints
1 parent ce0b39a commit 0c2629b

6 files changed

Lines changed: 103 additions & 2 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# DAppNodeSDK release directories
2-
build_*
3-
build/
2+
build_*/
43

54
# SDK artifacts
65
releases.json

‎build/postgres/Dockerfile‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG POSTGRES_MAJOR=17
2+
ARG POSTGRES_MINOR=7
3+
ARG POSTGRES_BASE=trixie
4+
5+
FROM postgres:${POSTGRES_MAJOR}.${POSTGRES_MINOR}-${POSTGRES_BASE}
6+
7+
ARG POSTGRES_MAJOR
8+
9+
RUN apt-get update && apt-get install -y \
10+
postgresql-${POSTGRES_MAJOR}-cron \
11+
&& rm -rf /var/lib/apt/lists/*

‎build/secrets/Dockerfile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:3.21
2+
3+
RUN apk add --no-cache openssl
4+
5+
COPY build/secrets/entrypoint.sh /entrypoint.sh
6+
RUN chmod +x /entrypoint.sh
7+
8+
ENTRYPOINT ["/entrypoint.sh"]

‎build/secrets/entrypoint.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
set -e
3+
4+
CONFIG_DIR="/config"
5+
6+
mkdir -p "$CONFIG_DIR"
7+
8+
if [ ! -f "$CONFIG_DIR/POSTGRES_PASSWORD" ]; then
9+
openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c32 > "$CONFIG_DIR/POSTGRES_PASSWORD"
10+
fi
11+
12+
if [ ! -f "$CONFIG_DIR/NEXTAUTH_SECRET" ]; then
13+
openssl rand -base64 32 > "$CONFIG_DIR/NEXTAUTH_SECRET"
14+
fi
15+
16+
sleep infinity

‎build/splitpro/Dockerfile‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:22.16.0-alpine3.21 AS base
2+
3+
RUN apk update && apk add --no-cache git
4+
5+
WORKDIR /app
6+
7+
RUN git clone --depth 1 --branch v2.1.3 https://github.com/oss-apps/split-pro.git .
8+
9+
ENV SKIP_ENV_VALIDATION=true
10+
ENV DOCKER_OUTPUT=1
11+
ENV NEXT_TELEMETRY_DISABLED=1
12+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
13+
ENV NEXT_PUBLIC_APP_VERSION=v2.1.3
14+
ENV NEXT_PUBLIC_GIT_SHA=dce49ae038b89b8bb83ea93a5f37e4747d3e181c
15+
16+
RUN npm i -g corepack@latest && corepack enable
17+
RUN pnpm install --frozen-lockfile
18+
RUN pnpm build
19+
20+
FROM node:22.16.0-alpine3.21 AS release
21+
22+
ENV NODE_ENV=production
23+
ENV DOCKER_OUTPUT=1
24+
25+
WORKDIR /app
26+
27+
RUN apk update && apk add --no-cache libc6-compat
28+
29+
COPY --from=base /app/.next/standalone ./
30+
COPY --from=base /app/.next/static ./.next/static
31+
COPY --from=base /app/public ./public
32+
COPY --from=base /app/prisma/migrations ./prisma/migrations
33+
COPY --from=base /app/start.sh ./start.sh
34+
COPY build/splitpro/entrypoint.sh ./entrypoint.sh
35+
36+
ENV SKIP_ENV_VALIDATION=false
37+
38+
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
39+
RUN mkdir -p /app/uploads && chown -R nextjs:nodejs /app
40+
USER nextjs
41+
42+
CMD ["sh", "entrypoint.sh"]

‎build/splitpro/entrypoint.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Process _FILE env vars — same logic as upstream start.sh
5+
# Reads secrets from files and exports them as env vars
6+
for file_var in $(env | grep -E '^[^=]+_FILE=' | cut -d'=' -f1); do
7+
base_var="${file_var%_FILE}"
8+
eval "file_path=\${$file_var:-}"
9+
eval "base_value=\${$base_var:-}"
10+
if [ -n "$base_value" ]; then continue; fi
11+
if [ -z "$file_path" ] || [ ! -f "$file_path" ] || [ ! -r "$file_path" ]; then continue; fi
12+
value=$(cat "$file_path" | tr -d '\n\r')
13+
eval "$base_var=\"$value\""
14+
export "$base_var"
15+
echo "Set $base_var from $file_var ($file_path)" >&2
16+
done
17+
18+
# Construct and EXPORT DATABASE_URL (upstream start.sh sets it but doesn't export it)
19+
if [ -z "$DATABASE_URL" ]; then
20+
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_CONTAINER_NAME}:${POSTGRES_PORT}/${POSTGRES_DB}"
21+
export DATABASE_URL
22+
echo "Exporting DATABASE_URL" >&2
23+
fi
24+
25+
exec sh start.sh

0 commit comments

Comments
 (0)