This project provides a set of tools and functions to manage Git repositories, run Go language tests, and build and publish Docker container images. It is designed to work within a containerized environment, leveraging the Dagger framework for seamless integration and execution.
The project is divided into several modules, each with its own specific functionality:
- Gitter Module: Provides a
Gitter
struct to manipulate Git repositories, including setting repository details and performing actions like checkout and inspect. - Container Image Module: Manages and builds Docker container images based on Git references. It includes methods to set various properties of the container image and generate appropriate Docker image tags.
- Golang Module: Provides functions to run Go language tests, lint Go source code, and publish Docker images.
- Kops Module: Provides functionality to set up and manage Kubernetes clusters using Kops and kubectl binaries.
- PulumiOps Module: Provides functionality to manage Pulumi operations, including setting Pulumi version, backend, credentials, and Kubernetes configuration.
Checkout
: Clones the repository and checks out the specified reference.
PublishFromRepo
: Publishes a container image to Docker Hub.
Test
: Runs Go language tests within a containerized environment.Lint
: Runs golangci-lint on the Go source code.Publish
: Builds and pushes a Docker image to a Docker registry.
ExportKubectl
: Exports the kubeconfig file for the specified Kops cluster to a specified output path.
DeployApp
: Deploys a backend application using Pulumi configurations and specified parameters.
To run the Dagger functions using the Dagger command line, follow these steps:
- Install Dagger CLI: Ensure you have the Dagger command line interface installed. You can download it from the official Dagger website.
- Initialize Dagger: Run
dagger init
in your project directory to initialize Dagger. - Run Functions: Use the
dagger call
command followed by the function name to execute the desired function. For example:
To set the Git reference and repository, and then check out the specified reference, you can use the following Dagger CLI command:
dagger -m gitter call with-ref --ref=develop with-repository \
--repository=https://github.com/dictybase-playground/gdrive-image-uploadr.git \
checkout entries
To export the kubeconfig file for a specified Kops cluster, you can use the following Dagger CLI command:
dagger -m kops call with-cluster --cluster=my-cluster with-state-storage \
--storage=s3://my-state-store with-credentials --credentials=/path/to/credentials.json \
export-kubectl --output=./mykube.yaml
To publish a container image to Docker Hub, you can use the following Dagger CLI command:
dagger -m container-image call with-namespace --namespace=my-namespace with-ref --ref=main \
with-repository --repository=my-repo with-dockerfile --dockerfile=./Dockerfile \
with-image --image=my-image publish-from-repo --user=my-dockerhub-user --password=my-dockerhub-password
To run Go language tests within a containerized environment, you can use the following Dagger CLI command:
dagger -m golang call test --version=go-1.21 --src=/path/to/source --args="-v ./..."
To run golangci-lint on the Go source code, you can use the following Dagger CLI command:
dagger -m golang call lint --version=v1.55.2-alpine --src=/path/to/source --args="run ./..."
To build and push a Docker image to a Docker registry, you can use the following Dagger CLI command:
dagger -m golang call publish --src=. --namespace=my-namespace --dockerfile=./Dockerfile \
--image=my-image --imageTag=latest
To deploy a backend application using Pulumi configurations and specified parameters, you can use the following Dagger CLI command:
dagger -m pulumi-ops call deploy-app --src=/path/to/source --project=backend_application \
--app=my-app --tag=latest --stack=dev