Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/rust:1": {}
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}
}
40 changes: 0 additions & 40 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


Expand All @@ -27,29 +19,15 @@ jobs:
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

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

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
with:
cosign-release: 'v1.13.1'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
Expand All @@ -58,16 +36,12 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
Expand All @@ -78,17 +52,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
27 changes: 7 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# -- SAIL-CLI -- #
FROM rustlang/rust:nightly AS sailcli

# Mirror source
COPY /sail /sail

# Build source
WORKDIR /sail
RUN cargo build --release

# Place Unix Executable
RUN cp /sail/target/release/sail /usr/local/sbin/



# -- SAILBOX -- #
FROM ubuntu:jammy
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN yes | unminimize

# -- Configuration -- #
Expand Down Expand Up @@ -54,12 +39,14 @@ RUN apt install curl -y

# Load entrypoint
COPY entrypoint.sh /
COPY sail-bash /sail-bash
RUN chmod +x /sail-bash/sail-bash.sh
COPY etc/ssh/sshd_config /etc/ssh/
# Wrapper-Skript für /usr/local/bin/sail
RUN echo '#!/bin/bash\nexec /sail-bash/sail-bash.sh "$@"' > /usr/local/bin/sail \
&& chmod +x /usr/local/bin/sail
RUN chmod +x /entrypoint.sh

# Sail-CLI
COPY --from=sailcli /usr/local/sbin/sail /usr/local/sbin/
RUN chmod +x /usr/local/sbin/sail


# -- Post -- #

Expand Down
115 changes: 99 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,114 @@
![sailbox](https://img.shields.io/github/actions/workflow/status/maxmielchen/sailbox/docker-publish.yml?label=sailbox%3Alatest&style=flat-square)

# Sailbox
Sailbox is a Docker image that simplifies the process of setting up a remote development environment. It includes basic tools for programming and provides CRUD options for managing SSH users. With Sailbox, you can easily set up a remote environment for any IDE or IDE-less coding setup.

## Basic usage
Sailbox is a Docker image that simplifies setting up a remote development environment. It includes essential programming tools and provides CRUD options for managing SSH users. With Sailbox, you can easily set up a remote environment for any IDE or even without an IDE.

Pull latest release
```Bash
docker pull ghcr.io/maxmielchen/sailbox:latest && docker image tag ghcr.io/maxmielchen/sailbox:latest sailbox:latest
```
---

## Table of Contents
- [Features](#features)
- [Quickstart (Docker CLI)](#quickstart-docker-cli)
- [Quickstart (Docker Compose)](#quickstart-docker-compose)
- [Sail CLI Commands](#sail-cli-commands)
- [Useful Commands](#useful-commands)

---

## Features
- SSH server out-of-the-box
- User management (CRUD) via the `sail` Bash CLI
- Docker-in-Docker support
- Preinstalled: Git, Vim, Neovim, Nano, curl, gh

---

## Quickstart (Docker CLI)

Pull from main
```Bash
docker pull ghcr.io/maxmielchen/sailbox:latest && docker image tag ghcr.io/maxmielchen/sailbox:main sailbox:latest
### Pull the image
```bash
docker pull ghcr.io/maxmielchen/sailbox:latest
```

Run instance
```Bash
docker run --name box -p 201:22 -v /var/run/docker.sock:/var/run/docker.sock -d sailbox:latest
### Start a container
```bash
docker run --name box -p 201:22 -v /var/run/docker.sock:/var/run/docker.sock -d ghcr.io/maxmielchen/sailbox:latest
```

Add user
```Bash
### Add a user
```bash
docker exec -it box sail user create --username OUR_USERNAME --password OUR_PASSWORD -r -s
```

Restart instance
```Bash
### Restart the container
```bash
docker restart box
```

---

## Quickstart (Docker Compose)

### Example `docker-compose.yml`
```yaml
services:
sailbox:
image: ghcr.io/maxmielchen/sailbox:latest
container_name: box
ports:
- "201:22"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
```

### Start
```bash
docker compose up -d
```

### Add a user
```bash
docker exec -it box sail user create --username OUR_USERNAME --password OUR_PASSWORD -r -s
```

---

## Sail CLI Commands

With the `sail` command (a symlink to the Bash script), you can manage users:

- **Create a user:**
```bash
sail user create --username USER --password PASS [-r] [-s]
# -r: Create user as root
# -s: Generate SSH key
```
- **Delete a user:**
```bash
sail user delete --username USER
```
- **Show help:**
```bash
sail help
```

---

## Useful Commands

- **Show logs:**
```bash
docker logs box
```
- **Stop the container:**
```bash
docker stop box
```
- **Remove the container:**
```bash
docker rm box
```

---

For more information, see the documentation in the `sail-bash/` folder.
1 change: 1 addition & 0 deletions etc/ssh/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ LogLevel INFO
UsePAM yes
X11Forwarding yes
PrintMotd no
PasswordAuthentication yes
Subsystem sftp /usr/lib/openssh/sftp-server
43 changes: 43 additions & 0 deletions sail-bash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# sail-bash

Alternative to `sail` completely in Bash. Provides the same CLI commands for user management (create/delete, root/sudo).

## Usage

```bash
./sail-bash.sh user create [--username USER] [--password PASS] [-r] [-s]
./sail-bash.sh user delete [--username USER]
./sail-bash.sh help
```

### Commands and Parameters

- `user create`
Create a new user with the following options:
- `--username USER` : The username for the new user. If omitted, you will be prompted interactively.
- `--password PASS` : The password for the new user. If omitted, you will be prompted interactively (input is hidden).
- `-r` : Add the user to the `root` group (root privileges).
- `-s` : Add the user to the `sudo` group (sudo privileges).

- `user delete`
Delete an existing user:
- `--username USER` : The username to delete. If omitted, you will be prompted interactively.

- `help` or `--help` or `-h`
Show this help message with all available commands and options.

### What happens when you create a user?
- The user is created on the system.
- The password is set.
- The user is added to the SSH AllowUsers list.
- A project directory is created at `/home/USER/projects`.
- The user is added to the `docker` group (Docker access).
- Optionally, the user is added to the `root` and/or `sudo` group if specified.

### What happens when you delete a user?
- The user is removed from the system (including home directory).
- The user is removed from the SSH AllowUsers list.

---

**Note:** After creating or deleting a user, you should reboot the Sailbox to fully apply the changes.
18 changes: 18 additions & 0 deletions sail-bash/cli/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# cli/action.sh
# Aktionen für user create/delete

parse_user() {
case $1 in
create)
shift
user_create "$@"
;;
delete)
shift
user_delete "$@"
;;
*)
show_help
;;
esac
}
41 changes: 41 additions & 0 deletions sail-bash/cli/dsl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# cli/dsl.sh
# CLI-Argumente parsen und weiterreichen

parse_cli() {
local args=("$@")
if [ ${#args[@]} -lt 1 ]; then
show_help
exit 1
fi
case ${args[0]} in
user)
shift
parse_user "$@"
;;
help|--help|-h)
show_help
;;
*)
show_help
;;
esac
}

show_help() {
echo "Usage:"
echo " sail-bash user create [--username USER] [--password PASS] [-r] [-s]"
echo " sail-bash user delete [--username USER]"
echo " sail-bash help"
echo
echo "Commands:"
echo " user create Create a new user."
echo " --username USER The username for the new user. If omitted, you will be prompted."
echo " --password PASS The password for the new user. If omitted, you will be prompted (input is hidden)."
echo " -r Add the user to the root group (root privileges)."
echo " -s Add the user to the sudo group (sudo privileges)."
echo " user delete Delete an existing user."
echo " --username USER The username to delete. If omitted, you will be prompted."
echo " help, --help, -h Show this help message."
echo
echo "After creating or deleting a user, reboot the Sailbox to fully apply the changes."
}
Loading
Loading