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
61 changes: 56 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
.env.example
# Git
.git
.gitignore
.gitattributes

# Docker
Dockerfile
docker-compose.yml
.dockerignore

# Documentation
README.md
exec.sh
exec.ps1
src/
pkg/
*.md

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Logs
*.log
logs/

# Temporary files
tmp/
temp/

# Build artifacts
bin/
dist/
build/

# Test files
*_test.go
test/
tests/

# Environment files (keep .env.example if you have one)
.env
.env.local
.env.production

# Node modules (if any)
node_modules/

# Go workspace files
go.work
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
AUTH0_CLIENT_ID={your-id-here}
AUTH0_DOMAIN=deeztop.auth0.com
AUTH0_DOMAIN=jackalpin.ca.auth0.com
AUTH0_CLIENT_SECRET={your-secret-here}
AUTH0_CALLBACK_URL=http://localhost:3049/callback
AUTH0_AUDIENCE=

DATABASE_URL=

SERVER_DOMAIN=http://localhost:3049

STRIPE_PUBLIC_KEY=
STRIPE_SOCKET_SECRET=

JACKAL_SEED={your-seed-here}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "colada"]
path = colada
url = https://github.com/JackalLabs/colada.git
213 changes: 213 additions & 0 deletions DOCKER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# IPFSPinner Docker Setup

This document describes how to run IPFSPinner using Docker and Docker Compose.

## Prerequisites

- Docker (version 20.10 or later)
- Docker Compose (version 2.0 or later)
- Make (optional, for using the Makefile commands)

## Quick Start

1. **Clone the repository and navigate to the project directory:**
```bash
cd IPFSPinner
```

2. **Set up environment variables:**
```bash
cp env.template .env
# Edit .env with your actual values
```

3. **Build and start the services:**
```bash
make build
make up
```

Or without Make:
```bash
docker-compose build
docker-compose up -d
```

4. **Check service status:**
```bash
make status
```

## Services

The Docker Compose setup includes the following services:

### 1. PostgreSQL Database (`postgres`)
- **Port:** 5432
- **Database:** ipfspinner
- **User:** ipfspinner
- **Password:** ipfspinner_password
- **Data Volume:** `postgres_data`

### 2. IPFS/Kubo Node (`ipfs`)
- **P2P Port:** 4001
- **API Port:** 5001
- **Gateway Port:** 8080
- **Data Volume:** `ipfs_data`
- **Staging Volume:** `ipfs_staging`

### 3. Colada Frontend (`colada`)
- **Port:** 3049
- **Type:** Vue.js SPA with Vite (Development Mode)
- **Features:** Hot reload, SPA routing, API proxy to backend
- **Environment:** Uses `VITE_API_BASE_URL` for backend API calls

### 4. IPFSPinner Application (`app`)
- **Port:** 3159
- **Depends on:** postgres, ipfs
- **Uploads Volume:** `./uploads`

### 5. Nginx Reverse Proxy (`nginx`) - Optional
- **Ports:** 80, 443
- **Depends on:** app

## Environment Variables

Create a `.env` file based on `env.template` with the following required variables:

- `DATABASE_URL`: PostgreSQL connection string
- `STRIPE_PUBLIC_KEY`: Your Stripe public key
- `JACKAL_SEED`: Your Jackal wallet seed phrase
- `JACKAL_RPC_URL`: Jackal blockchain RPC endpoint (e.g., http://35.193.64.216:26657)
- `JACKAL_GRPC_URL`: Jackal blockchain gRPC endpoint (e.g., 35.193.64.216:9090)

## Useful Commands

### Using Make (recommended)
```bash
make help # Show all available commands
make up # Start services
make down # Stop services
make logs # Show logs
make clean # Clean up everything
make shell-app # Shell into app container
make shell-db # Connect to database
make shell-ipfs # Shell into IPFS container
```

### Using Docker Compose directly
```bash
docker-compose up -d # Start services in background
docker-compose down # Stop services
docker-compose logs -f # Follow logs
docker-compose exec app sh # Shell into app container
docker-compose exec postgres psql -U ipfspinner -d ipfspinner # Database shell
```

## Development Workflow

1. **Start services:**
```bash
make up
```

2. **View logs:**
```bash
make logs
```

3. **Make code changes and rebuild:**
```bash
make down
make build
make up
```

4. **Access services:**
- Application: http://localhost:3159
- IPFS Gateway: http://localhost:8080
- IPFS API: http://localhost:5001
- Colada Frontend: http://localhost:3049
- Database: localhost:5432

## Database Management

### Backup
```bash
make backup-db
```

### Restore
```bash
make restore-db backup_file=backup_20241201_120000.sql
```

### Reset
```bash
make clean
make up
```

## IPFS Configuration

After starting the IPFS container for the first time, you may want to configure CORS headers:

```bash
make init-ipfs
```

This configures the IPFS node to allow cross-origin requests from your application.

## Troubleshooting

### Service won't start
1. Check logs: `make logs`
2. Verify environment variables are set correctly
3. Check if ports are already in use
4. Ensure Docker has enough resources allocated

### Database connection issues
1. Verify PostgreSQL is running: `make status`
2. Check database logs: `make logs-db`
3. Verify DATABASE_URL in .env file

### IPFS issues
1. Check IPFS logs: `make logs-ipfs`
2. Verify IPFS node is accessible: `curl http://localhost:5001/api/v0/version`
3. Check if IPFS data volume has proper permissions

### Colada Frontend issues
1. Check Colada logs: `make logs-colada`
2. Verify frontend is accessible: `curl http://localhost:3000/health`
3. Rebuild frontend if needed: `make build-colada`

### Application issues
1. Check application logs: `make logs-app`
2. Verify all environment variables are set
3. Check if the application can connect to database and IPFS

## Scaling

Scale the application service:
```bash
make scale-app scale-app=3
```

## Cleanup

To completely remove all containers, networks, and volumes:
```bash
make clean
```

This will remove all data. Use with caution in production!

## Production Considerations

- Change default passwords in docker-compose.yml
- Use external PostgreSQL database for production
- Configure proper SSL certificates for nginx
- Set up monitoring and logging
- Use Docker secrets for sensitive environment variables
- Configure proper backup strategies
- Set up health checks and restart policies
56 changes: 44 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
FROM golang:1.19.3-alpine3.17
# Build stage
FROM golang:1.23-alpine AS builder

# Define current working directory
WORKDIR /01-Login
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata

# Download modules to local cache so we can skip re-
# downloading on consecutive docker build commands
COPY go.mod .
COPY go.sum .
# Set working directory
WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Add sources
# Copy source code
COPY . .

RUN go build -o out/auth0-go-web-app .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

# Final stage
FROM alpine:latest

# Install runtime dependencies
RUN apk --no-cache add ca-certificates tzdata

# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup

# Set working directory
WORKDIR /app

# Copy binary from builder stage
COPY --from=builder /app/main .

# Change ownership to non-root user
RUN chown -R appuser:appgroup /app

# Switch to non-root user
USER appuser

# Expose port
EXPOSE 3159

# Expose port 3000 for our web app binary
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3159/health || exit 1

CMD ["/01-Login/out/auth0-go-web-app"]
# Run the application
CMD ["./main"]
Loading
Loading