mirror of
https://github.com/ovosimpatico/smtp-loadbalancer.git
synced 2026-01-15 08:23:37 -03:00
Docker support
This commit is contained in:
38
.dockerignore
Normal file
38
.dockerignore
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Data
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
config.json
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
docs/
|
||||||
|
README.md
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.dockerignore
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
50
.github/workflows/docker-build-push.yml
vendored
Normal file
50
.github/workflows/docker-build-push.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
FROM node:24-alpine
|
||||||
|
|
||||||
|
# Install netcat for healthcheck
|
||||||
|
RUN apk add --no-cache netcat-openbsd
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm ci --only=production
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY src/ ./src/
|
||||||
|
|
||||||
|
# Create directories for logs and data
|
||||||
|
RUN mkdir -p /app/logs /app/data
|
||||||
|
|
||||||
|
# Expose SMTP port
|
||||||
|
EXPOSE 2525
|
||||||
|
|
||||||
|
# Set environment variable for config path
|
||||||
|
ENV CONFIG_PATH=/app/config/config.json
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
CMD ["node", "src/index.js"]
|
||||||
19
README.md
19
README.md
@@ -44,24 +44,27 @@ For deployment:
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
TODO: Docker support
|
### Using Docker (Recommended)
|
||||||
### Using Docker (Recommended) TODO
|
|
||||||
|
|
||||||
1. Clone the repository:
|
1. Create a directory for your configuration:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ovosimpatico/smtp-loadbalancer.git
|
mkdir smtp-loadbalancer && cd smtp-loadbalancer
|
||||||
cd smtp-loadbalancer
|
|
||||||
```
|
```
|
||||||
2. Make your `config.json` file based on the [example file](config.example.json)
|
2. Download the example configuration and docker-compose file:
|
||||||
|
```bash
|
||||||
|
curl -O https://raw.githubusercontent.com/ovosimpatico/smtp-loadbalancer/main/config.example.json
|
||||||
|
curl -O https://raw.githubusercontent.com/ovosimpatico/smtp-loadbalancer/main/docker-compose.yml
|
||||||
|
```
|
||||||
|
3. Create your `config.json` file:
|
||||||
```bash
|
```bash
|
||||||
cp config.example.json config.json
|
cp config.example.json config.json
|
||||||
nano config.json
|
nano config.json
|
||||||
```
|
```
|
||||||
3. Run the application:
|
4. Run the application:
|
||||||
```bash
|
```bash
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
```
|
```
|
||||||
4. The SMTP server will be listening on port `2525`.
|
5. The SMTP server will be listening on port `2525`.
|
||||||
|
|
||||||
### Native Node.js Installation
|
### Native Node.js Installation
|
||||||
|
|
||||||
|
|||||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
services:
|
||||||
|
smtp-loadbalancer:
|
||||||
|
container_name: smtp-loadbalancer
|
||||||
|
image: ghcr.io/ovosimpatico/smtp-loadbalancer:latest
|
||||||
|
# build:
|
||||||
|
# context: .
|
||||||
|
# dockerfile: Dockerfile
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
# Config file
|
||||||
|
- ./config.json:/app/config/config.json:ro
|
||||||
|
# Logs
|
||||||
|
- ./logs:/app/logs
|
||||||
|
# Email queue DB
|
||||||
|
- ./data:/app/data
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- CONFIG_PATH=/app/config/config.json
|
||||||
|
ports:
|
||||||
|
- "2525:2525"
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-z", "localhost", "2525"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 10s
|
||||||
Reference in New Issue
Block a user