diff --git a/.dockerignore b/.dockerignore index 29936490..ae84fa66 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,11 @@ node_modules android ios build + +# Git +.git +.gitignore + +# Env files (keep .env for build; exclude local overrides) +.env.local +.env.*.local \ No newline at end of file diff --git a/.env.local b/.env.local new file mode 100644 index 00000000..fe8387e3 --- /dev/null +++ b/.env.local @@ -0,0 +1,3 @@ +# VITE_PLATFORM_URL=http://localhost:1847 +# VITE_PLATFORM_RELAYS=wss://relay.nostrtalk.org/ +VITE_POMADE_SIGNERS=https://pomade.coracle.social,https://pomade.fiatjaf.com,http://localhost:3003 diff --git a/Dockerfile b/Dockerfile index 71905be1..18f909db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,30 @@ -FROM node:20-slim +# Stage 1: Build +# Uses .env from build context for config (logo, branding, etc.) +# Optional: docker build --build-arg VITE_BUILD_HASH=$(git rev-parse --short HEAD) -t flotilla . + +FROM node:20-bookworm AS builder -# Install pnpm RUN npm install -g pnpm@latest -# Set working directory WORKDIR /app -# Copy package files COPY package.json pnpm-lock.yaml ./ - -# Install dependencies RUN pnpm i -# Copy the rest of the application +# Copy everything (including .env when present) - build.sh will source it COPY . . -# Build the application +ARG VITE_BUILD_HASH +ENV VITE_BUILD_HASH=${VITE_BUILD_HASH} + ENV NODE_OPTIONS=--max_old_space_size=16384 RUN pnpm run build -# Default to serving the build directory -CMD ["npx", "serve", "-s", "build"] +FROM node:20-alpine +WORKDIR /app + +# Copy only the built output - no source, no .env, no dev deps +COPY --from=builder /app/build ./build + +CMD ["npx", "serve", "-s", "build"] diff --git a/README.md b/README.md index 29e880ec..a60d384a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can also optionally create an `.env` file and populate it with the following - `VITE_DEFAULT_PUBKEYS` - A comma-separated list of hex pubkeys for bootstrapping web of trust - `VITE_PLATFORM_URL` - The url where the app will be hosted - `VITE_PLATFORM_NAME` - The name of the app -- `VITE_PLATFORM_LOGO` - A logo url for the app +- `VITE_PLATFORM_LOGO` - A logo url for the app. Can be a local path or https link. Must be a PNG file. - `VITE_PLATFORM_RELAYS` - A list of comma-separated relay urls that will make flotilla operate in "platform mode". Disables all space browse/add/select functionality and makes the first platform relay the home page. - `VITE_PLATFORM_ACCENT` - A hex color for the app's accent color - `VITE_PLATFORM_DESCRIPTION` - A description of the app diff --git a/build.sh b/build.sh index 252fde49..1b632f25 100755 --- a/build.sh +++ b/build.sh @@ -5,6 +5,9 @@ temp_env=$(declare -p -x) if [ -f .env.template ]; then source .env.template fi +if [ -f .env ]; then + source .env +fi # Avoid overwriting env vars provided directly # https://stackoverflow.com/a/69127685/1467342 @@ -14,12 +17,13 @@ if [[ -z $VITE_BUILD_HASH ]]; then export VITE_BUILD_HASH=$(git rev-parse --short HEAD) fi -if [[ $VITE_PLATFORM_LOGO =~ ^https://* ]]; then - curl $VITE_PLATFORM_LOGO > static/logo.png +if [[ $VITE_PLATFORM_LOGO =~ ^https:// ]]; then + curl -fSL "$VITE_PLATFORM_LOGO" -o static/logo.png export VITE_PLATFORM_LOGO=static/logo.png fi -npx pwa-assets-generator +# Ensure generator uses local path (dotenv may have loaded URL from .env) +VITE_PLATFORM_LOGO="${VITE_PLATFORM_LOGO}" npx pwa-assets-generator npx vite build # Replace index.html variables with stuff from our env diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38bdb75a..d447fc03 100644 Binary files a/pnpm-lock.yaml and b/pnpm-lock.yaml differ