Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Dependencies
node_modules/
**/node_modules/

# Build outputs
dist/
**/dist/
build/
**/build/

# Git
.git/
.gitignore

# IDE
.vscode/
.idea/

# OS files
.DS_Store
Thumbs.db

# Logs
*.log
npm-debug.log*

# Test files
coverage/
**/*.test.ts
**/*.test.js
**/*.spec.ts
**/*.spec.js

# Documentation
docs/
*.md

# Docker files (avoid recursive copies)
docker/
Dockerfile*

# Environment files (use docker-compose env instead)
.env
.env.*
!.env.example

# QA tests
qaAutomationTests/
46 changes: 46 additions & 0 deletions docker/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Digital Safe Server Environment Variables for Local Development
# Copy this to server/.env when running the server locally with Docker infrastructure

# ============================================
# Core Settings
# ============================================
ENVIRONMENT=DEVELOPMENT
PORT=2999

# ============================================
# Authentication
# ============================================
AUTH_TOKEN=dev_auth_token_12345_change_in_production

# ============================================
# PostgreSQL (Docker container)
# ============================================
POSTGRES_HOST=localhost
POSTGRES_USER=digitalsafe
POSTGRES_DB_NAME=digitalsafe
POSTGRES_PASSWORD=digitalsafe_dev_password

# ============================================
# Redis (Docker container)
# ============================================
REDIS_URL=redis://localhost:6379
REDIS_PASSWORD=redis_dev_password
REDIS_USE_TLS=false

# ============================================
# Azure Storage (Azurite emulator)
# ============================================
AZURE_CONNECTION_STRING=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;
AZURE_ACCOUNT_NAME=devstoreaccount1
AZURE_ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==

# ============================================
# Application Settings
# ============================================
DIGITAL_SAFE_DOMAIN=localhost

# ============================================
# Optional Services
# ============================================
KUTT_URL=https://old.tinylink.me/
SENTRY_EXPRESS_DSN=
23 changes: 23 additions & 0 deletions docker/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Digital Safe Client Dockerfile (Development)

Check notice

Code scanning / Trivy

No HEALTHCHECK defined Low

Artifact: docker/Dockerfile.client
Type: dockerfile
Vulnerability DS026
Severity: LOW
Message: Add HEALTHCHECK instruction in your Dockerfile
Link: DS026
FROM node:20-alpine

WORKDIR /app

# Copy package files for client
COPY client/package*.json ./client/

# Install client dependencies
WORKDIR /app/client
RUN npm ci

# Copy client source code
COPY client/ ./

# Expose Vite dev server port
EXPOSE 5173

# Use non-root user for security
USER node

# Start Vite dev server with host binding for Docker
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
36 changes: 36 additions & 0 deletions docker/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Digital Safe Server Dockerfile

Check notice

Code scanning / Trivy

No HEALTHCHECK defined Low

Artifact: docker/Dockerfile.server
Type: dockerfile
Vulnerability DS026
Severity: LOW
Message: Add HEALTHCHECK instruction in your Dockerfile
Link: DS026
FROM node:20-alpine

# Install build dependencies for native modules (argon2)
RUN apk add --no-cache python3 make g++ libc6-compat

WORKDIR /app

# Copy package files for server
COPY server/package*.json ./server/

# Install server dependencies
WORKDIR /app/server
RUN npm ci

# Copy server source code
COPY server/ ./

# Copy shared files if needed
COPY custom-types/ /app/custom-types/
COPY custom-webgl-ext.d.ts /app/

# Build TypeScript
RUN npm run build

# Set working directory to dist for running
WORKDIR /app/server/dist

# Expose port
EXPOSE 2999

# Use non-root user for security
USER node

# Start the server
CMD ["node", "./server.js"]
130 changes: 130 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Digital Safe - Docker Development Setup

This directory contains Docker configuration for local development.

## Prerequisites

- Docker Desktop installed and running
- Docker Compose (included with Docker Desktop)

## Quick Start

### Option 1: Infrastructure Only (Recommended for Development)

Start only the database and storage services, then run the app locally:

```bash
# From the docker directory
cd docker

# Start PostgreSQL, Redis, and Azurite
docker-compose up -d postgres redis azurite

# Wait for services to be healthy
docker-compose ps

# Now run the app locally from the project root
cd ..
npm run dev:win # Windows
# or
npm run dev # Mac/Linux
```

### Option 2: Full Stack in Docker

Run everything in Docker containers:

```bash
# From the docker directory
cd docker

# Start all services including server
docker-compose up -d

# Or include the client as well
docker-compose --profile with-client up -d
```

## Services

| Service | Port | Description |
|-----------|-------|---------------------------------|
| postgres | 5432 | PostgreSQL database |
| redis | 6379 | Redis cache |
| azurite | 10000 | Azure Blob Storage emulator |
| server | 2999 | Express API server |
| client | 5173 | Vite dev server (optional) |

## Environment Variables

Copy `.env` and modify as needed. The default values work for local development.

### Connecting to Services Locally

When running the app locally (not in Docker), use these connection settings:

```env
# PostgreSQL
POSTGRES_HOST=localhost
POSTGRES_USER=digitalsafe
POSTGRES_PASSWORD=digitalsafe_dev_password
POSTGRES_DB_NAME=digitalsafe

# Redis
REDIS_URL=redis://localhost:6379
REDIS_PASSWORD=redis_dev_password
REDIS_USE_TLS=false

# Azure Storage (Azurite)
AZURE_CONNECTION_STRING=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;
```

## Common Commands

```bash
# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f

# View logs for specific service
docker-compose logs -f postgres

# Reset database (removes all data)
docker-compose down -v
docker-compose up -d

# Rebuild containers after code changes
docker-compose build --no-cache
docker-compose up -d

# Connect to PostgreSQL
docker exec -it digitalsafe-postgres psql -U digitalsafe -d digitalsafe

# Connect to Redis
docker exec -it digitalsafe-redis redis-cli -a redis_dev_password
```

## Troubleshooting

### Port already in use
If you get port conflicts, either stop the conflicting service or modify the ports in `docker-compose.yml`.

### Database not initializing
The init script only runs on first startup. To re-run it:
```bash
docker-compose down -v # Remove volumes
docker-compose up -d # Start fresh
```

### Server can't connect to services
Make sure services are healthy:
```bash
docker-compose ps
```

All services should show "healthy" or "Up" status.
Loading
Loading