-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
757eb58
commit 23a1a07
Showing
11 changed files
with
355 additions
and
31 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 |
---|---|---|
@@ -1,7 +1,38 @@ | ||
*~ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
docker-volume-moosefs | ||
*.rpm | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
vendor/ | ||
|
||
# Plugin build artifacts | ||
plugin/rootfs/ | ||
*.deb | ||
obj | ||
.idea | ||
vendor/*/ | ||
*.rpm | ||
obj/ | ||
|
||
# IDE specific files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
|
||
# OS generated files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
|
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,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Colors for output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' | ||
|
||
# Version | ||
VERSION="0.2.0" | ||
PLUGIN_NAME="moosefs/docker-volume-moosefs:${VERSION}" | ||
|
||
# Function to print step | ||
print_step() { | ||
echo -e "${YELLOW}[*] $1${NC}" | ||
} | ||
|
||
# Function to print success | ||
print_success() { | ||
echo -e "${GREEN}[+] $1${NC}" | ||
} | ||
|
||
# Function to print error and exit | ||
print_error() { | ||
echo -e "${RED}[-] $1${NC}" | ||
exit 1 | ||
} | ||
|
||
# Clean previous build | ||
print_step "Cleaning previous build..." | ||
rm -rf plugin/rootfs *.deb *.rpm docker-volume-moosefs obj | ||
print_success "Clean completed" | ||
|
||
# Clean existing plugin if it exists | ||
print_step "Checking for existing plugin..." | ||
if docker plugin inspect ${PLUGIN_NAME} >/dev/null 2>&1; then | ||
print_step "Disabling existing plugin..." | ||
docker plugin disable ${PLUGIN_NAME} >/dev/null 2>&1 | ||
print_step "Removing existing plugin..." | ||
docker plugin rm ${PLUGIN_NAME} >/dev/null 2>&1 | ||
fi | ||
print_success "Plugin cleanup completed" | ||
|
||
# Build Go binary | ||
print_step "Building Go binary..." | ||
go build || print_error "Go build failed" | ||
print_success "Binary built successfully" | ||
|
||
# Create plugin | ||
print_step "Creating Docker plugin..." | ||
mkdir -p plugin/rootfs || print_error "Failed to create plugin directory" | ||
|
||
# Build Docker image | ||
print_step "Building Docker image..." | ||
docker build -t moosefs-plugin-build -f plugin/Dockerfile . || print_error "Docker build failed" | ||
|
||
print_step "Creating temporary container..." | ||
docker create --name tmp moosefs-plugin-build || print_error "Failed to create temporary container" | ||
|
||
print_step "Extracting rootfs..." | ||
docker export tmp | tar -x -C plugin/rootfs || print_error "Failed to extract rootfs" | ||
|
||
print_step "Cleaning up temporary container..." | ||
docker rm -vf tmp | ||
docker rmi moosefs-plugin-build | ||
|
||
# Create and enable plugin | ||
print_step "Creating Docker plugin..." | ||
docker plugin create ${PLUGIN_NAME} plugin || print_error "Failed to create plugin" | ||
|
||
print_step "Enabling Docker plugin..." | ||
docker plugin enable ${PLUGIN_NAME} || print_error "Failed to enable plugin" | ||
|
||
print_success "Build completed successfully!" | ||
echo -e "${GREEN}Plugin ${PLUGIN_NAME} is now ready to use${NC}" | ||
echo -e "${YELLOW}You can create a volume with:${NC}" | ||
echo -e "docker volume create -d ${PLUGIN_NAME} --name test_volume" |
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,18 @@ | ||
module github.com/liberodark/docker-volume-moosefs | ||
|
||
go 1.21 | ||
|
||
toolchain go1.23.3 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 | ||
github.com/docker/go-plugins-helpers v0.0.0-20211224144127-6eecb7beb651 | ||
github.com/sirupsen/logrus v1.9.3 | ||
) | ||
|
||
require ( | ||
github.com/Microsoft/go-winio v0.6.2 // indirect | ||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect | ||
github.com/docker/go-connections v0.5.0 // indirect | ||
golang.org/x/sys v0.10.0 // indirect | ||
) |
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,24 @@ | ||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= | ||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= | ||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= | ||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= | ||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= | ||
github.com/docker/go-plugins-helpers v0.0.0-20211224144127-6eecb7beb651 h1:YcvzLmdrP/b8kLAGJ8GT7bdncgCAiWxJZIlt84D+RJg= | ||
github.com/docker/go-plugins-helpers v0.0.0-20211224144127-6eecb7beb651/go.mod h1:LFyLie6XcDbyKGeVK6bHe+9aJTYCxWLBg5IrJZOaXKA= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= | ||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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
Oops, something went wrong.