Fix a docker rebuild issue #88
@@ -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
|
||||
+17
-10
@@ -1,24 +1,31 @@
|
||||
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", "build"]
|
||||
# Stage 2: Runtime
|
||||
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", "build"]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
mplorentz
commented
This fixes an issue I had with setting the logo. You could configure the other vars in This fixes an issue I had with setting the logo. You could configure the other vars in `.env` because npx reads that automatically but the logo was being read here and wasn't respecting .env.
|
||||
|
||||
# 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
|
||||
|
mplorentz
commented
The old curl command was failing silently for me so this one will fail the build if the logo URL exists but the logo cannot be fetched. The old curl command was failing silently for me so this one will fail the build if the logo URL exists but the logo cannot be fetched.
|
||||
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
|
||||
|
||||
Generated
+444
-365
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user
I changed this to a two-stage docker build mostly because include .env in an image seems dangerous even if none of the env values are secrets at this time.