Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidedg committed Dec 18, 2024
0 parents commit f59a311
Show file tree
Hide file tree
Showing 32 changed files with 10,461 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.git
.gitignore
node_modules
dist
*.log
.env*
.vscode
.idea
README.md
accounts/
*.sqlite
*.db
LOCAL_NOTES_*
51 changes: 51 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Build and Publish

on:
push:
tags:
- 'v*' # Trigger on version tags

env:
REGISTRY: docker.io
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/webgyb

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
/dist
/accounts
LOCAL_NOTES_*
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# syntax=docker/dockerfile:1.4

# Build stage with architecture-specific optimizations
FROM --platform=$BUILDPLATFORM node:20-slim AS builder

# Add build platform argument for better cross-compilation
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "Building on $BUILDPLATFORM for $TARGETPLATFORM"

WORKDIR /app

# Install build dependencies including sharp requirements
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*

# Update npm and configure settings (with platform-specific optimizations)
ENV NODE_OPTIONS="--max-old-space-size=3072"
RUN npm install -g npm@latest && \
npm config set fund false && \
npm config set update-notifier false

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm install --legacy-peer-deps --no-audit --no-fund

# Copy source files
COPY . .

# Build the application
RUN npm run build

# Runtime stage
FROM --platform=$TARGETPLATFORM node:20-slim AS runner

# Install tini and curl with platform-specific considerations
RUN apt-get update && \
apt-get install -y --no-install-recommends \
tini \
curl \
ca-certificates && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy only production files from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package.json .

# Set environment variables
ENV HOST=0.0.0.0 \
PORT=3000 \
NODE_ENV=production \
TINI_SUBREAPER=true \
NODE_OPTIONS="--max-old-space-size=1024"

# Expose port
EXPOSE 3000

# Use tini as entrypoint with subreaper enabled
ENTRYPOINT ["/usr/bin/tini", "-s", "--"]
CMD ["node", "./dist/server/entry.mjs"]
145 changes: 145 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# ![WebGYB Logo](public/favicon.svg) WebGYB

A web interface for viewing GMail backups created by [Got-Your-Back (GYB)](https://github.com/GAM-team/got-your-back)

[![Build](https://img.shields.io/github/actions/workflow/status/davidedg/webgyb/docker-publish.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/davidedg/webgyb/actions/workflows/docker.yml) [![davidedg/webgyb](https://img.shields.io/docker/pulls/davidedg/webgyb?style=for-the-badge&logo=docker)](https://hub.docker.com/r/davidedg/webgyb)


<div align="center">
<img src="interface-preview.gif" alt="WebGYB Interface Preview" width="800"/>
</div>

---

## Features

- **Multi-Account Support**
- Switch between multiple GMail accounts seamlessly
- **Labels Management**
- Support for GMail labels
- Label counts and organization
- **Safe Rendering**
- Secure email content rendering (enabled by default)
- Protection against malicious content
- Sanitized HTML display
- **Email Management**
- View original email source
- Download emails in EML format
- **Multi-platform support (amd64,arm64,armv7)**
- **Under Development**
- Attachment handling
- Improved UX and responsiveness
- Search Feature

## Docker Quick Start

```bash
docker pull davidedg/gybweb
docker run -d -p 3000:3000 -v "/path/to/gyb/accounts:/app/accounts" davidedg/gybweb
```

Where `/path/to/gyb/accounts` is the path to a directory structure like this:

```
accounts/
└── {account1}/
├── msg-db.sqlite
└── {email_folders}/
└── {account2}/
├── msg-db.sqlite
└── {email_folders}/
...
```
The application will be available at `http://localhost:3000`

## Docker Compose Quick Start

```yaml
services:
webgyb:
image: davidedg/webgyb
container_name: webgyb
init: true
user: "1000:1000"
ports:
- "3000:3000"
volumes:
- /path/to/gyb/accounts:/app/accounts:ro
- /path/to/a/standalone/account1/app/accounts/account1:ro
- /path/to/a/standalone/account2/app/accounts/account2:ro
environment:
- PUID=1000
- PGID=1000
- NODE_ENV=production
- HOST=0.0.0.0
- PORT=3000
- GYB_ACCOUNTS_DIR=/app/accounts
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
```
The application will be available at `http://localhost:3000`


## Development

1. Clone the repository:
```bash
git clone https://github.com/davidedg/webgyb.git
cd webgyb
```

2. Install dependencies:
```bash
npm install
```

3. Start the application in development mode:
```bash
npm run dev
```

The application will be available at `http://localhost:4321`

## Building for Production

Create a production build:

```bash
npm run build
```

The built files will be in the `dist` directory.

## Building Docker Images

- [Dockerfile](Dockerfile)
- [docker-build.sh](docker-build.sh)


## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## Support

If you find WebGYB useful, please consider supporting it:

[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=ff69b4)](https://github.com/sponsors/davidedg) <a href="https://www.buymeacoffee.com/davidedg" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-violet.png" alt="Buy Me A Coffee" style="height: 20px !important;width: 72px !important;"></a>

---

<div align="center">
Made with ❤️ by <a href="https://github.com/davidedg">davidedg</a>
</div>
12 changes: 12 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'astro/config';
import svelte from '@astrojs/svelte';
import tailwind from '@astrojs/tailwind';
import node from '@astrojs/node';

export default defineConfig({
integrations: [svelte(), tailwind()],
output: 'server',
adapter: node({
mode: 'standalone'
})
});
Loading

0 comments on commit f59a311

Please sign in to comment.