Skip to content

Commit 129c9f5

Browse files
authored
Merge pull request #146 from powerloom/feat/docker_setup
Docker Setup Enhancement
2 parents b96a08e + af9a8bf commit 129c9f5

File tree

7 files changed

+479
-96
lines changed

7 files changed

+479
-96
lines changed

.github/workflows/docker-publish.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ env:
2323
jobs:
2424
build:
2525

26-
runs-on:
27-
group: larger-runners
26+
runs-on: warp-ubuntu-latest-x64-4x
2827
permissions:
2928
contents: read
3029
packages: write
@@ -34,7 +33,7 @@ jobs:
3433

3534
steps:
3635
- name: Checkout repository
37-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3837
with:
3938
submodules: recursive
4039

@@ -47,18 +46,13 @@ jobs:
4746
# cosign-release: 'v1.11.0'
4847

4948
- name: Set up QEMU
50-
uses: docker/setup-qemu-action@v2
51-
52-
53-
# Workaround: https://github.com/docker/build-push-action/issues/461
54-
- name: Setup Docker buildx
55-
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
49+
uses: docker/setup-qemu-action@v3
5650

5751
# Login against a Docker registry except on PR
5852
# https://github.com/docker/login-action
5953
- name: Log into registry ${{ env.REGISTRY }}
6054
if: github.event_name != 'pull_request'
61-
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
55+
uses: docker/login-action@v3
6256
with:
6357
registry: ${{ env.REGISTRY }}
6458
username: ${{ github.actor }}
@@ -68,15 +62,15 @@ jobs:
6862
# https://github.com/docker/metadata-action
6963
- name: Extract Docker metadata
7064
id: meta
71-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
65+
uses: docker/metadata-action@v5
7266
with:
7367
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7468

75-
# Build and push Docker image with Buildx (don't push on PR)
76-
# https://github.com/docker/build-push-action
69+
# Build and push Docker image with WarpBuild Docker builder
70+
# https://docs.warpbuild.com/ci/docker-builders
7771
- name: Build and push Docker image
7872
id: build-and-push
79-
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
73+
uses: Warpbuilds/build-push-action@v6
8074
with:
8175
context: .
8276
platforms: linux/amd64,linux/arm64

Dockerfile.setup

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM alpine:3.18
2+
3+
# Install required tools for configuration
4+
RUN apk update && apk add --no-cache \
5+
bash \
6+
curl \
7+
wget \
8+
jq \
9+
git \
10+
findutils \
11+
coreutils \
12+
grep \
13+
sed \
14+
gawk
15+
16+
# Set working directory
17+
WORKDIR /app
18+
19+
# Copy the configuration script
20+
COPY configure-environment.sh /app/
21+
COPY env.example /app/
22+
23+
# Make the script executable
24+
RUN chmod +x /app/configure-environment.sh
25+
26+
# Default command
27+
CMD ["bash", "-c", "echo 'Setup container ready. Run configure-environment.sh to setup environment.'"]

build-docker.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
docker build -t snapshotter-lite-v2 .
1+
docker build -t snapshotter-lite-v2 .
2+
3+
#!/bin/bash
4+
5+
# Build the setup image
6+
echo "🏗️ Building snapshotter-lite-setup image..."
7+
docker build -f Dockerfile.setup -t snapshotter-lite-setup:latest .
8+
9+
if [ $? -eq 0 ]; then
10+
echo "✅ Setup image built successfully"
11+
else
12+
echo "❌ Failed to build setup image"
13+
exit 1
14+
fi

build.sh

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,70 @@
11
#!/bin/bash
22

3-
# Run configuration
4-
source ./configure-environment.sh "$@"
5-
if [ $? -ne 0 ]; then
6-
echo "❌ Configuration failed"
3+
# Parse arguments to check for dev mode and other flags
4+
DEV_MODE=false
5+
SETUP_ARGS=""
6+
7+
for arg in "$@"; do
8+
case $arg in
9+
--dev-mode)
10+
DEV_MODE=true
11+
;;
12+
*)
13+
SETUP_ARGS="$SETUP_ARGS $arg"
14+
;;
15+
esac
16+
done
17+
18+
# Build the setup container first
19+
echo "🏗️ Building setup container..."
20+
docker build -f Dockerfile.setup -t snapshotter-lite-setup:latest .
21+
22+
# Create a temporary file to capture the env file path from setup
23+
SETUP_RESULT_FILE=$(mktemp)
24+
25+
# Run setup container directly
26+
echo "🔧 Running setup container to configure environment..."
27+
docker run --rm -it \
28+
-v "$(pwd):/app" \
29+
-v "$SETUP_RESULT_FILE:/tmp/setup_result" \
30+
-w /app \
31+
snapshotter-lite-setup:latest \
32+
bash -c "./configure-environment.sh $SETUP_ARGS --docker-mode"
33+
34+
# Remove the setup container image
35+
docker rmi snapshotter-lite-setup:latest
36+
37+
# Check if setup was successful by reading the result file
38+
if [ -f "$SETUP_RESULT_FILE" ] && [ -s "$SETUP_RESULT_FILE" ]; then
39+
SELECTED_ENV_FILE=$(cat "$SETUP_RESULT_FILE")
40+
rm -f "$SETUP_RESULT_FILE"
41+
42+
if [ -n "$SELECTED_ENV_FILE" ] && [ -f "$SELECTED_ENV_FILE" ]; then
43+
echo "ℹ️ Setup container configured: $SELECTED_ENV_FILE"
44+
else
45+
echo "❌ Setup container failed to report a valid env file."
46+
echo " Reported: '$SELECTED_ENV_FILE'"
47+
echo " This indicates a problem with the configuration process."
48+
exit 1
49+
fi
50+
else
51+
echo "❌ Setup container did not complete successfully or failed to report results."
52+
rm -f "$SETUP_RESULT_FILE"
753
exit 1
854
fi
955

56+
# Source the environment file to get variables
57+
source "$SELECTED_ENV_FILE"
58+
59+
# Ensure FULL_NAMESPACE is available
60+
if [ -z "$FULL_NAMESPACE" ]; then
61+
echo "❌ FULL_NAMESPACE not found in $SELECTED_ENV_FILE"
62+
exit 1
63+
fi
1064

11-
# Source the environment file
12-
source ".env-${FULL_NAMESPACE}"
65+
# Export variables so they're available to child scripts
66+
export FULL_NAMESPACE
67+
export NO_COLLECTOR
1368

1469
if [ "$DEV_MODE" != "true" ]; then
1570
# Set image tag based on git branch
@@ -65,14 +120,14 @@ export FULL_NAMESPACE_LOWER
65120

66121
COMPOSE_PROFILES="${COLLECTOR_PROFILE_STRING}"
67122

68-
# Modify the deploy-services call to use the profiles
123+
# Modify the deploy-services call to use the profiles (setup already ran)
69124
if [ "$DEV_MODE" == "true" ]; then
70-
./deploy-services.sh --env-file ".env-${FULL_NAMESPACE}" \
125+
./deploy-services.sh --env-file "$SELECTED_ENV_FILE" \
71126
--project-name "$PROJECT_NAME_LOWER" \
72127
--collector-profile "$COMPOSE_PROFILES" \
73128
--dev-mode
74129
else
75-
./deploy-services.sh --env-file ".env-${FULL_NAMESPACE}" \
130+
./deploy-services.sh --env-file "$SELECTED_ENV_FILE" \
76131
--project-name "$PROJECT_NAME_LOWER" \
77132
--collector-profile "$COMPOSE_PROFILES" \
78133
--image-tag "$IMAGE_TAG"

0 commit comments

Comments
 (0)