Add docker
This commit is contained in:
1 parent
f1dc11111d
commit
dddd68ccf3
4 files changed
+129
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
data
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
docker-compose.yaml
|
||||||
|
*.md
|
||||||
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
timing_*.json
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Docker Setup for flog
|
||||||
|
|
||||||
|
This directory contains Docker configuration to run the flog finance/expense logger in a containerized environment.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Docker Engine (version 20.10+)
|
||||||
|
- Docker Compose (version 2.0+)
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
1. Build and start the container:
|
||||||
|
```bash
|
||||||
|
docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Open your browser and navigate to:
|
||||||
|
```text
|
||||||
|
http://localhost:3010
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Stop the container:
|
||||||
|
```bash
|
||||||
|
docker compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
- The app runs on port `3010` by default (both inside the container and exposed to host).
|
||||||
|
- `config.json` is copied into the image at build time. If you need to change the port or validator string, update `config.json` and rebuild.
|
||||||
|
- User data is persisted in the `./data` directory on the host (bind-mounted to `/app/data` in the container). This directory contains user wallets and shared keys.
|
||||||
|
|
||||||
|
## Docker Image
|
||||||
|
|
||||||
|
The Dockerfile uses a multi-stage build:
|
||||||
|
1. **deps**: Installs dependencies with `npm ci`
|
||||||
|
2. **build**: Builds both client (`react-scripts build`) and server (`tsc -p tsconfig.server.json`), then prunes dev dependencies
|
||||||
|
3. **runtime**: Copies built artifacts (`dist/`, `build/`), `config.json`, `index.js`, and production dependencies
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- The server serves the built React client from `build/` and mounts the API at `/api`.
|
||||||
|
- The container runs as root to ensure write access to the bind-mounted `./data` directory. If you prefer a non-root user, uncomment the `USER node` directive in the Dockerfile (note that the mounted `./data` directory must be owned by UID 1000).
|
||||||
|
- Pre-existing `build/` and `dist/` directories in the repo are not used when building the image — the image builds them fresh from source.
|
||||||
|
- The build sets `CI=false` so CRA warnings don't cause build failures.
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
# Multi-stage Dockerfile for flog
|
||||||
|
# Build: deps -> build -> runtime
|
||||||
|
|
||||||
|
# Stage 1: Dependencies
|
||||||
|
FROM node:20-slim AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Stage 2: Build
|
||||||
|
FROM node:20-slim AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy dependencies
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Set environment for CRA build (avoid treating warnings as errors)
|
||||||
|
ENV CI=false
|
||||||
|
|
||||||
|
# Build client and server
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Prune dev dependencies
|
||||||
|
RUN npm prune --omit=dev
|
||||||
|
|
||||||
|
# Stage 3: Runtime
|
||||||
|
FROM node:20-slim AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy built assets and runtime files
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
COPY --from=build /app/build ./build
|
||||||
|
COPY --from=build /app/package.json ./package.json
|
||||||
|
COPY --from=build /app/node_modules ./node_modules
|
||||||
|
COPY config.json ./config.json
|
||||||
|
COPY index.js ./index.js
|
||||||
|
COPY index.ts ./index.ts
|
||||||
|
|
||||||
|
# Create data directory
|
||||||
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 3010
|
||||||
|
|
||||||
|
# Run the server
|
||||||
|
CMD ["node", "dist/index.js"]
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
services:
|
||||||
|
flog:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "3010:3010"
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
restart: unless-stopped
|
||||||
Reference in new issue
Block a user