Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
chore: add docker build files, and scripts
Kyle Mendell6505e66b8466
diff --git a/.version b/.versionnew file mode 100644index 000000000..6c6aa7cb0--- /dev/null+++ b/.version@@ -0,0 +1 @@+0.1.0\ No newline at end of filediff --git a/CHANGELOG.md b/CHANGELOG.mdnew file mode 100644index 000000000..e69de29bbdiff --git a/Dockerfile b/Dockerfilenew file mode 100644index 000000000..a72762b35--- /dev/null+++ b/Dockerfile@@ -0,0 +1,67 @@+# ---- Base Node ----+# Use a specific Node.js version on Alpine for smaller images+FROM node:22-alpine AS base+WORKDIR /app+# Copy package.json and lock file separately to leverage Docker cache+COPY package.json package-lock.json* ./++# ---- Dependencies ----+# Install only production dependencies first+FROM base AS prod-deps+RUN npm install --omit=dev++# ---- Build ----+# Install all dependencies (including dev) and build the app+FROM base AS builder+# Copy production node_modules from the previous stage+COPY --from=prod-deps /app/node_modules ./node_modules+# Install dev dependencies needed for build+RUN npm install+# Copy the rest of the application source code+COPY . .+# Run the SvelteKit build command+RUN npm run build++# ---- Runner ----+# Use a clean Node.js Alpine image for the final stage+FROM node:22-alpine AS runner+WORKDIR /app++# Install su-exec (needed by the entrypoint script) and bash (often useful for scripts)+RUN apk add --no-cache su-exec bash++# Set environment variables+ENV NODE_ENV=production+# Set HOST for adapter-node to listen on all interfaces within the container+ENV HOST=0.0.0.0+# Set PORT (optional, adapter-node defaults to 3000 if not set)+# ENV PORT=3000+# Default PUID/PGID (can be overridden in docker-compose.yml)+ENV PUID=1000+ENV PGID=1000++# Copy necessary artifacts from previous stages+# Copy production dependencies+COPY --from=prod-deps /app/node_modules ./node_modules+# Copy the built application output+COPY --from=builder /app/build ./build+# Copy package.json (needed by adapter-node runner)+COPY --from=builder /app/package.json ./package.json+# Copy the settings file if it exists at build time (optional, usually mounted as a volume)+# COPY --from=builder /app/app-settings.json ./app-settings.json++# Copy the entrypoint script and make it executable+COPY scripts/docker/entrypoint.sh /usr/local/bin/entrypoint.sh+RUN chmod +x /usr/local/bin/entrypoint.sh++# NOTE: User creation and ownership changes are now handled by the entrypoint script+# We run as root initially, and the entrypoint script switches user++# Expose the port the application runs on (default for adapter-node is 3000)+EXPOSE 3000++# Set the entrypoint+ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]++# Command to start the Node.js server (passed as arguments to the entrypoint)+CMD ["node", "build"]\ No newline at end of filediff --git a/README.md b/README.mdindex b5b295070..203cb997a 100644--- a/README.md+++ b/README.md@@ -1,38 +1,94 @@-# sv+# Arcane - Docker Management UI-Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).+Arcane is a web-based user interface built with SvelteKit to interact with and manage your Docker environment. It provides a clean overview of your containers, images, volumes, and networks, along with controls for common Docker operations.-## Creating a project+## Features-If you're seeing this, you've probably already done this step. Congrats!+- **Dashboard:** Overview of your Docker environment (coming soon).+- **Containers:** List, inspect, start, stop, restart, and remove containers. View container logs.+- **Images:** List and remove images.+- **Volumes:** List and manage Docker volumes.+- **Networks:** List and manage Docker networks.+- **Settings:** Configure Docker connection details (Host/Socket Path) and application preferences.+- **Responsive UI:** Built with shadcn-svelte and Tailwind CSS for a modern look and feel.-```bash-# create a new project in the current directory-npx sv create+## Technology Stack-# create a new project in my-app-npx sv create my-app-```+- **Frontend:** SvelteKit, TypeScript+- **UI Components:** shadcn-svelte+- **Styling:** Tailwind CSS+- **Docker Interaction:** Dockerode (Node.js client for the Docker Engine API)+- **Deployment:** Docker Compose-## Developing+## Prerequisites-Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:+- **Docker:** The Docker Engine must be installed and running.+- **Docker Compose:** Required for running the application via the provided configuration.+- **Node.js & npm/pnpm/yarn:** Required only for local development.-```bash-npm run dev+## Getting Started (Docker Compose - Recommended)-# or start the server and open the app in a new browser tab-npm run dev -- --open-```+This is the easiest way to run Arcane, as it bundles the application and its dependencies.++1. **Clone the repository:**++ ```bash+ git clone <your-repository-url> arcane+ cd arcane+ ```++2. **Docker Socket Access:**+ The provided `docker-compose.yml` file mounts the Docker socket (`/var/run/docker.sock`) into the Arcane container. This allows Arcane to communicate with your local Docker Engine. Ensure the path to the Docker socket is correct for your system if it differs.++3. **Build and Run:**++ ```bash+ docker-compose up -d --build+ ```++ - `--build`: Builds the Docker image for Arcane based on the `Dockerfile`.+ - `-d`: Runs the containers in detached mode (in the background).++4. **Access Arcane:**+ Open your web browser and navigate to `http://localhost:5173` (or the port specified in your `docker-compose.yml` if you changed it).-## Building+## Development (Local)-To create a production version of your app:+If you want to contribute or run the application locally for development:++1. **Clone the repository:**++ ```bash+ git clone <your-repository-url> arcane+ cd arcane+ ```++2. **Install dependencies:**++ ```bash+ npm install+ # or pnpm install / yarn install+ ```++3. **Configure Docker Connection:**+ By default, Arcane will try to connect to the Docker socket at `/var/run/docker.sock`. If your Docker setup is different, you can modify the default in `src/lib/services/docker-service.ts` or configure it via the Settings page once the application is running (settings are saved to `app-settings.json` in the project root).++4. **Start the development server:**+ ```bash+ npm run dev -- --open+ ```+ This will start the SvelteKit development server, typically on `http://localhost:5173`.++## Configuration++Application settings, including the Docker host connection string, can be configured via the **Settings** page within the Arcane UI. These settings are persisted in the `app-settings.json` file in the project's root directory. When running via Docker Compose, this file will exist _inside_ the container unless you map a volume to persist it externally.++## Building for Production (Standalone)++While Docker Compose is recommended, you can build a production version of the SvelteKit app:```bashnpm run build```-You can preview the production build with `npm run preview`.--> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.+This requires a Node.js environment to run. You'll need an adapter (like `adapter-node`) configured in `svelte.config.js` for standalone deployment. See the [SvelteKit documentation on adapters](https://kit.svelte.dev/docs/adapters) for more details. You can preview the build locally with `npm run preview`.diff --git a/docker-compose.yml b/docker-compose.ymlnew file mode 100644index 000000000..1ca82e7f8--- /dev/null+++ b/docker-compose.yml@@ -0,0 +1,37 @@+services:+ arcane:+ # Build the image using the Dockerfile in the current directory (.)+ image: ghcr.io/ofkm/arcane:latest+ container_name: arcane+ ports:+ # Map host port 5173 to the container's exposed port 3000+ - "3000:3000"+ volumes:+ # Mount the Docker socket to allow Arcane to interact with the Docker Engine+ - /var/run/docker.sock:/var/run/docker.sock:ro # Read-only is often safer if Arcane only needs to read info++ # Optional: Mount a volume to persist the settings file outside the container+ # Create a directory named 'arcane-data' in the same directory as this compose file+ # The entrypoint script will ensure correct permissions if PUID/PGID are set+ - ./arcane-data:/app # Mount the data directory to the app's root+ # Note: If you mount /app, ensure app-settings.json is within this mount+ # Or mount specifically the settings file:+ # - ./arcane-data/app-settings.json:/app/app-settings.json++ environment:+ # Set the User and Group ID for file permissions.+ # The entrypoint script will use these to set ownership.+ # Use 'id -u' and 'id -g' on your host machine to find your user/group ID.+ - PUID=1000+ - PGID=1000+ # NODE_ENV is already set in the Dockerfile, but can be overridden here if needed+ # - NODE_ENV=production+ # PORT is already set in the Dockerfile (defaults to 3000), override if needed+ # - PORT=3000+ # HOST is already set in the Dockerfile (0.0.0.0)+ # - HOST=0.0.0.0+ restart: unless-stopped++# Optional: Define the volume if you want Docker to manage it+# volumes:+# arcane-data:\ No newline at end of filediff --git a/scripts/development/create-release.sh b/scripts/development/create-release.shnew file mode 100644index 000000000..a8c82170e--- /dev/null+++ b/scripts/development/create-release.sh@@ -0,0 +1,124 @@+# Check if the script is being run from the root of the project+if [ ! -f .version ] || [ ! -f package.json ] || [ ! -f CHANGELOG.md ]; then+ echo "Error: This script must be run from the root of the project."+ exit 1+fi++# Read the current version from .version+VERSION=$(cat .version)++# Function to increment the version+increment_version() {+ local version=$1+ local part=$2++ IFS='.' read -r -a parts <<<"$version"+ if [ "$part" == "major" ]; then+ parts[0]=$((parts[0] + 1))+ parts[1]=0+ parts[2]=0+ elif [ "$part" == "minor" ]; then+ parts[1]=$((parts[1] + 1))+ parts[2]=0+ elif [ "$part" == "patch" ]; then+ parts[2]=$((parts[2] + 1))+ fi+ echo "${parts[0]}.${parts[1]}.${parts[2]}"+}++# Determine the release type+if [ "$1" == "major" ]; then+ RELEASE_TYPE="major"+else+ # Get the latest tag+ LATEST_TAG=$(git describe --tags --abbrev=0)++ # Check for "feat" or "fix" in the commit messages since the latest tag+ if git log "$LATEST_TAG"..HEAD --oneline | grep -q "feat"; then+ RELEASE_TYPE="minor"+ elif git log "$LATEST_TAG"..HEAD --oneline | grep -q "fix"; then+ RELEASE_TYPE="patch"+ else+ echo "No 'fix' or 'feat' commits found since the latest release. No new release will be created."+ exit 0+ fi+fi++# Increment the version based on the release type+if [ "$RELEASE_TYPE" == "major" ]; then+ echo "Performing major release..."+ NEW_VERSION=$(increment_version $VERSION major)+elif [ "$RELEASE_TYPE" == "minor" ]; then+ echo "Performing minor release..."+ NEW_VERSION=$(increment_version $VERSION minor)+elif [ "$RELEASE_TYPE" == "patch" ]; then+ echo "Performing patch release..."+ NEW_VERSION=$(increment_version $VERSION patch)+else+ echo "Invalid release type. Please enter either 'major', 'minor', or 'patch'."+ exit 1+fi++# Confirm release creation+read -p "This will create a new $RELEASE_TYPE release with version $NEW_VERSION. Do you want to proceed? (y/n) " CONFIRM+if [[ "$CONFIRM" != "y" ]]; then+ echo "Release process canceled."+ exit 1+fi++# Update the .version file with the new version+echo $NEW_VERSION >.version+git add .version++# Update version in frontend/package.json+jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json >package_tmp.json && mv package_tmp.json package.json+git add frontend/package.json++# Check if conventional-changelog is installed, if not install it+if ! command -v conventional-changelog &>/dev/null; then+ echo "conventional-changelog not found, installing..."+ npm install -g conventional-changelog-cli+fi++# Generate changelog+echo "Generating changelog..."+conventional-changelog -p conventionalcommits -i CHANGELOG.md -s+git add CHANGELOG.md++# Commit the changes with the new version+git commit -m "release: $NEW_VERSION"++# Create a Git tag with the new version+git tag "v$NEW_VERSION"++# Push the commit and the tag to the repository+git push+git push --tags++# Check if GitHub CLI is installed+if ! command -v gh &>/dev/null; then+ echo "GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'."+ exit 1+fi++# Extract the changelog content for the latest release+echo "Extracting changelog content for version $NEW_VERSION..."+CHANGELOG=$(awk '/^## / {if (NR > 1) exit} NR > 1 {print}' CHANGELOG.md | awk 'NR > 2 || NF {print}')++if [ -z "$CHANGELOG" ]; then+ echo "Error: Could not extract changelog for version $NEW_VERSION."+ exit 1+fi++# Create the release on GitHub+echo "Creating GitHub release..."+gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --notes "$CHANGELOG"++if [ $? -eq 0 ]; then+ echo "GitHub release created successfully."+else+ echo "Error: Failed to create GitHub release."+ exit 1+fi++echo "Release process complete. New version: $NEW_VERSION"diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.shnew file mode 100644index 000000000..aa10fbe02--- /dev/null+++ b/scripts/docker/entrypoint.sh@@ -0,0 +1,62 @@+#!/bin/bash++# Exit immediately if a command exits with a non-zero status.+set -e++# If we aren't running as root, just exec the CMD+if [ "$(id -u)" -ne 0 ]; then+ exec "$@"+fi++echo "Entrypoint: Running as root. Setting up user and permissions..."++# Default PUID/PGID if not provided+PUID=${PUID:-1000}+PGID=${PGID:-1000}+APP_USER="arcane"+APP_GROUP="arcane-group"+APP_DIR="/app"+# Optional: Define a data directory if you mount volumes for settings/data+# DATA_DIR="/app/data"++echo "Entrypoint: Using PUID=${PUID}, PGID=${PGID}"++# Create the group if it doesn't exist+if ! getent group "$PGID" > /dev/null 2>&1; then+ echo "Entrypoint: Creating group ${APP_GROUP} with GID ${PGID}..."+ addgroup -g "$PGID" "$APP_GROUP"+else+ # If group with PGID exists, find its name+ APP_GROUP=$(getent group "$PGID" | cut -d: -f1)+ echo "Entrypoint: Group with GID ${PGID} already exists: ${APP_GROUP}"+fi++# Create the user if it doesn't exist+if ! getent passwd "$PUID" > /dev/null 2>&1; then+ echo "Entrypoint: Creating user ${APP_USER} with UID ${PUID}..."+ adduser -D -u "$PUID" -G "$APP_GROUP" -h "$APP_DIR" -s /bin/bash "$APP_USER"+else+ # If user with PUID exists, find their name+ APP_USER=$(getent passwd "$PUID" | cut -d: -f1)+ echo "Entrypoint: User with UID ${PUID} already exists: ${APP_USER}"+ # Ensure the existing user is part of the target group+ if ! id -nG "$APP_USER" | grep -qw "$APP_GROUP"; then+ echo "Entrypoint: Adding existing user ${APP_USER} to group ${APP_GROUP}..."+ addgroup "$APP_USER" "$APP_GROUP"+ fi+fi++# Change ownership of application directories+echo "Entrypoint: Ensuring ownership of ${APP_DIR} for ${PUID}:${PGID}..."+# Use chown -R for simplicity on the main app directory+chown -R "$PUID":"$PGID" "$APP_DIR"++# Optional: Change ownership of a separate data directory if used+# if [ -d "$DATA_DIR" ]; then+# echo "Entrypoint: Ensuring ownership of ${DATA_DIR} for ${PUID}:${PGID}..."+# chown -R "$PUID":"$PGID" "$DATA_DIR"+# fi++# Execute the command passed to the script (CMD) as the specified user/group+echo "Entrypoint: Switching to user ${APP_USER} (${PUID}:${PGID}) and executing command: $@"+exec su-exec "$PUID":"$PGID" "$@"