-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
230 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Release Dockside Agent | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.CR_PAT }} | ||
|
||
- name: Get short commit hash | ||
id: vars | ||
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)" | ||
|
||
- name: Build and push Docker image with inline cache | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
dockerfile: ./Dockerfile-agent | ||
platforms: linux/amd64 | ||
push: true | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/dockside:cache | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/dockside:cache,mode=max | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/dockside-agent:latest | ||
ghcr.io/${{ github.repository_owner }}/dockside-agent:${{ steps.vars.outputs.short_sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Stage 1: Build the Go binary | ||
FROM golang:1.23-alpine AS builder | ||
|
||
RUN apk update | ||
RUN apk add git | ||
RUN apk add curl | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy go.mod and go.sum files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download and cache the Go modules | ||
RUN go mod download | ||
|
||
# Copy the source code into the container | ||
COPY . . | ||
|
||
# Build the Go binary for Linux | ||
RUN go build -o ./dist/dockside-agent ./cmd/agent | ||
|
||
|
||
# Stage 2: Create the smallest possible image | ||
FROM gcr.io/distroless/base-debian11 | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy the Go binary from the builder stage | ||
COPY --from=builder /app/dist . | ||
|
||
# Command to run the binary | ||
CMD ["./dockside-agent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Pull the latest image | ||
docker pull ghcr.io/maddalax/dockside-agent:latest | ||
|
||
# Stop and remove the existing container, if any | ||
docker stop dockside 2>/dev/null || true | ||
docker rm dockside 2>/dev/null || true | ||
|
||
# Determine the volume mount path | ||
if [[ "$(uname)" != "Linux" ]]; then | ||
VOLUME_PATH="$HOME/.dockside/data" | ||
else | ||
VOLUME_PATH="/data/dockside" | ||
fi | ||
|
||
# Run the container | ||
docker run -d \ | ||
--name dockside \ | ||
--restart unless-stopped \ | ||
-p 80:80 \ | ||
-p 8100:3000 \ | ||
-p 4222:4222 \ | ||
-v "${VOLUME_PATH}:/data/dockside" \ | ||
ghcr.io/maddalax/dockside-agent:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Configuration | ||
REMOTE_USER="root" # Replace with remote SSH username | ||
REMOTE_HOST="fedora-server" # Replace with remote host address or IP | ||
REMOTE_PATH="/tmp/dockside.tar" # Temporary path for the tar file on the remote machine | ||
LOCAL_IMAGE_NAME="ghcr.io/maddalax/dockside:latest" | ||
CONTAINER_NAME="dockside" | ||
|
||
# Step 1: Build the image locally (if needed) | ||
docker build -t "$LOCAL_IMAGE_NAME" . | ||
|
||
# Step 2: Export the image to a tar file | ||
IMAGE_TAR="dockside.tar" | ||
docker save -o "$IMAGE_TAR" "$LOCAL_IMAGE_NAME" | ||
|
||
# Step 3: Transfer the tar file to the remote machine | ||
scp "$IMAGE_TAR" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH" | ||
|
||
# Step 4: Load the image on the remote machine and run the container | ||
ssh "$REMOTE_USER@$REMOTE_HOST" << EOF | ||
set -e | ||
# Load the Docker image | ||
docker load < "$REMOTE_PATH" | ||
# Remove the temporary tar file | ||
rm -f "$REMOTE_PATH" | ||
# Pull the latest image to ensure updates | ||
docker pull "$LOCAL_IMAGE_NAME" | ||
# Stop and remove the existing container if it exists | ||
docker stop "$CONTAINER_NAME" 2>/dev/null || true | ||
docker rm "$CONTAINER_NAME" 2>/dev/null || true | ||
# Determine the volume mount path | ||
if [[ "\$(uname)" != "Linux" ]]; then | ||
VOLUME_PATH="\$HOME/.dockside/data" | ||
else | ||
VOLUME_PATH="/data/dockside" | ||
fi | ||
# Run the container | ||
docker run -d \ | ||
--name "$CONTAINER_NAME" \ | ||
--restart unless-stopped \ | ||
-p 80:80 \ | ||
-p 8100:3000 \ | ||
-p 4222:4222 \ | ||
-v "\${VOLUME_PATH}:/data/dockside" \ | ||
"$LOCAL_IMAGE_NAME" | ||
EOF | ||
|
||
# Step 5: Cleanup local tar file | ||
rm -f "$IMAGE_TAR" | ||
|
||
echo "Docker image deployed and running on $REMOTE_HOST." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Configuration | ||
REMOTE_USER="root" # Replace with remote SSH username | ||
REMOTE_HOST="fedora-server" # Replace with remote host address or IP | ||
REMOTE_PATH="/tmp/dockside.tar" # Temporary path for the tar file on the remote machine | ||
LOCAL_IMAGE_NAME="ghcr.io/maddalax/dockside:latest" | ||
CONTAINER_NAME="dockside" | ||
|
||
# Step 1: Build the image locally (if needed) | ||
docker build -t "$LOCAL_IMAGE_NAME" . | ||
|
||
# Step 2: Export the image to a tar file | ||
IMAGE_TAR="dockside.tar" | ||
docker save -o "$IMAGE_TAR" "$LOCAL_IMAGE_NAME" | ||
|
||
# Step 3: Transfer the tar file to the remote machine | ||
scp "$IMAGE_TAR" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH" | ||
|
||
# Step 4: Load the image on the remote machine and run the container | ||
ssh "$REMOTE_USER@$REMOTE_HOST" << EOF | ||
set -e | ||
# Load the Docker image | ||
docker load < "$REMOTE_PATH" | ||
# Remove the temporary tar file | ||
rm -f "$REMOTE_PATH" | ||
# Pull the latest image to ensure updates | ||
docker pull "$LOCAL_IMAGE_NAME" | ||
# Stop and remove the existing container if it exists | ||
docker stop "$CONTAINER_NAME" 2>/dev/null || true | ||
docker rm "$CONTAINER_NAME" 2>/dev/null || true | ||
# Determine the volume mount path | ||
if [[ "\$(uname)" != "Linux" ]]; then | ||
VOLUME_PATH="\$HOME/.dockside/data" | ||
else | ||
VOLUME_PATH="/data/dockside" | ||
fi | ||
# Run the container | ||
docker run -d \ | ||
--name "$CONTAINER_NAME" \ | ||
--restart unless-stopped \ | ||
-p 80:80 \ | ||
-p 8100:3000 \ | ||
-p 4222:4222 \ | ||
-v "\${VOLUME_PATH}:/data/dockside" \ | ||
"$LOCAL_IMAGE_NAME" | ||
EOF | ||
|
||
# Step 5: Cleanup local tar file | ||
rm -f "$IMAGE_TAR" | ||
|
||
echo "Docker image deployed and running on $REMOTE_HOST." |