# How to Deploy Static Assets with Dewy: Complete Configuration Guide

> Deploy static assets with Dewy. This guide covers configuration to download, extract, and manage releases with atomic symlinks without server processes. Learn asset deployment now.

- Repository: [Tomohisa Oda/dewy](https://github.com/linyows/dewy)
- Tags: how-to-guide
- Published: 2026-03-06

---

**Dewy's assets command downloads versioned archives from supported registries, extracts them into a designated directory, and maintains an atomic `current` symlink that always points to the latest release without managing any server processes.**

The `linyows/dewy` repository provides a lightweight deployment tool that treats static files as versioned artifacts. When you deploy static assets with Dewy, the tool polls your registry, caches downloads to prevent redundant network requests, and atomically updates file paths using a symlink-based release directory structure.

## How the Dewy Assets Command Works

The **Assets** command mirrors the behavior of the `server` command but intentionally skips process management. Instead of starting or restarting services, it focuses solely on file system operations: downloading archives, verifying cache integrity, extracting contents to timestamped release directories, and atomically repointing the `current` symlink.

### Deployment Architecture and Source Files

Dewy’s asset deployment pipeline consists of discrete components that handle specific responsibilities:

| Component | Source File | Role in Asset Deployment |
|-----------|-------------|--------------------------|
| **CLI Parser** | `cli.go:72-74` | Detects the `assets` sub-command and initializes the configuration with `Command = ASSETS`. |
| **Configuration** | [`config.go`](https://github.com/linyows/dewy/blob/main/config.go) | Stores the destination directory (`Dir`) and global options like cache paths. |
| **Registry** | [`registry/ghr.go`](https://github.com/linyows/dewy/blob/main/registry/ghr.go) | Queries the registry (e.g., GitHub Releases) via `Current()` to retrieve the latest artifact metadata. |
| **Artifact** | [`artifact/ghr.go`](https://github.com/linyows/dewy/blob/main/artifact/ghr.go) | Downloads the static asset archive using the URL provided by the registry. |
| **Cache** | [`kvs/file.go`](https://github.com/linyows/dewy/blob/main/kvs/file.go) | Persists downloaded artifacts to prevent redundant network requests. |
| **Core Logic** | `dewy.go:302-304` | Checks if the cached version matches the latest release; if not, extracts the archive and updates the `current` symlink. |
| **Notifier** | [`notifier/slack.go`](https://github.com/linyows/dewy/blob/main/notifier/slack.go) | Optionally sends deployment confirmations after successful asset updates. |

The deployment flow follows these steps:

1. **Poll registry** → `Current()` returns the newest artifact metadata.
2. **Cache check** → If the cache already contains this version, Dewy logs *"Deploy skipped"* and returns (`dewy.go:302`).
3. **Download** → The artifact is fetched and stored in the cache ([`kvs/file.go`](https://github.com/linyows/dewy/blob/main/kvs/file.go)).
4. **Extract** → The archive is unpacked into a timestamped release directory (`releases/<ts>/`).
5. **Symlink** → `releases/<ts>` becomes the new `current` link via atomic replacement.
6. **Notify** → The notifier sends confirmation that assets for the new tag are live.

## Deploy Static Assets with Dewy: Practical Examples

The following examples demonstrate how to deploy static assets with Dewy using different configurations and deployment strategies.

### Basic One-Shot Deployment

Execute a single deployment that pulls the latest release and exits:

```bash
dewy assets \
  --registry ghr://myorg/myfrontend \
  -d /var/www/html \
  -l info

```

This command downloads the archive from GitHub Releases (`ghr://`), extracts it to `/var/www/html`, and creates a `current` symlink pointing to the release directory.

### Continuous Polling for Auto-Updates

For environments requiring automatic updates, run Dewy as a background process with an interval:

```bash
dewy assets \
  --registry ghr://myorg/myfrontend \
  -d /var/www/html \
  --interval 30s

```

Dewy checks the registry every 30 seconds. When it detects a new version, it downloads, extracts, and atomically switches the `current` symlink without downtime.

### Slack Notifications for Asset Changes

Integrate notifications to alert your team when static assets update:

```bash
dewy assets \
  --registry ghr://myorg/myfrontend \
  -d /var/www/html \
  --notifier "slack://#deployments?title=MyApp&quiet=true"

```

When the deployment completes, Dewy sends a concise message to the specified Slack channel confirming the new version is live.

### Container-Optimized Deployment with Custom Cache

In containerized environments, persist the cache to avoid re-downloading artifacts on every restart:

```bash
export DEWY_CACHEDIR=/app/cache
dewy assets \
  --registry ghr://myorg/myfrontend \
  -d /var/www/html

```

The cache directory at `/app/cache/.dewy` stores downloaded archives, ensuring fast restarts and reduced bandwidth usage.

## Summary

Deploying static assets with Dewy provides an atomic, zero-downtime update mechanism for versioned file archives. The key takeaways include:

- The **assets** command treats static files as versioned artifacts, skipping process management while maintaining the same reliable deployment pipeline as the server command.
- Dewy uses a **cache** ([`kvs/file.go`](https://github.com/linyows/dewy/blob/main/kvs/file.go)) to avoid redundant downloads and only triggers extraction when the registry reports a new version (`dewy.go:302-304`).
- The **current** symlink provides atomic updates, ensuring that web servers always serve a consistent set of files even during extraction.
- Integration with **notifiers** like Slack keeps teams informed of deployment status without manual monitoring.

## Frequently Asked Questions

### What archive formats does Dewy support for static assets?

Dewy supports standard compression formats including **ZIP**, **tar.gz**, and **tar** archives. The tool automatically detects the archive type during extraction in the core logic ([`dewy.go`](https://github.com/linyows/dewy/blob/main/dewy.go)) and handles decompression appropriately regardless of the specific format provided by the registry.

### How does Dewy handle failed asset deployments?

If the download or extraction fails, Dewy aborts the deployment before updating the `current` symlink. Because the symlink switch occurs only after successful extraction into a timestamped release directory (`releases/<ts>/`), a failed deployment leaves the existing `current` link untouched, preserving the previous working version of your static assets.

### Can I use Dewy assets with private GitHub repositories?

Yes, Dewy supports private repositories through the GitHub Releases registry ([`registry/ghr.go`](https://github.com/linyows/dewy/blob/main/registry/ghr.go)). You must configure authentication using a **GitHub token** passed via environment variables or configuration. The registry implementation handles the authenticated API requests necessary to list releases and download artifacts from private repositories.

### What is the difference between `dewy server` and `dewy assets`?

The **`server`** command manages long-running processes by downloading artifacts, extracting them, and restarting services when new versions appear. The **`assets`** command (`cli.go:72-74`) uses the same download and extraction pipeline but skips process management entirely, focusing solely on maintaining the `current` symlink for static file serving. Use `server` for applications requiring process supervision and `assets` for static websites or file bundles.