Browse Source

improve docker build

pull/7185/head
chrislu 1 month ago
parent
commit
f1008b554e
  1. 48
      .github/workflows/e2e.yml
  2. 13
      docker/Dockerfile.e2e
  3. 9
      docker/Makefile
  4. 24
      docker/compose/e2e-mount.yml

48
.github/workflows/e2e.yml

@ -32,14 +32,54 @@ jobs:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v2 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-e2e-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-e2e-
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update
sudo apt-get install -y fuse
# Use faster mirrors and install with timeout
echo "deb http://azure.archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" | sudo tee /etc/apt/sources.list
echo "deb http://azure.archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt-get update --fix-missing
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends fuse
# Verify FUSE installation
echo "FUSE version: $(fusermount --version 2>&1 || echo 'fusermount not found')"
echo "FUSE device: $(ls -la /dev/fuse 2>&1 || echo '/dev/fuse not found')"
- name: Start SeaweedFS - name: Start SeaweedFS
timeout-minutes: 5
run: make build_e2e && docker compose -f ./compose/e2e-mount.yml up --wait
timeout-minutes: 10
run: |
# Enable Docker buildkit for better caching
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
# Build with retry logic
for i in {1..3}; do
echo "Build attempt $i/3"
if make build_e2e; then
echo "Build successful on attempt $i"
break
elif [ $i -eq 3 ]; then
echo "Build failed after 3 attempts"
exit 1
else
echo "Build attempt $i failed, retrying in 30 seconds..."
sleep 30
fi
done
# Start services with wait
docker compose -f ./compose/e2e-mount.yml up --wait
- name: Run FIO 4k - name: Run FIO 4k
timeout-minutes: 15 timeout-minutes: 15

13
docker/Dockerfile.e2e

@ -2,7 +2,18 @@ FROM ubuntu:22.04
LABEL author="Chris Lu" LABEL author="Chris Lu"
RUN apt-get update && apt-get install -y curl fio fuse
# Use faster mirrors and optimize package installation
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
--no-install-recommends \
--no-install-suggests \
curl \
fio \
fuse \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/*
RUN mkdir -p /etc/seaweedfs /data/filerldb2 RUN mkdir -p /etc/seaweedfs /data/filerldb2
COPY ./weed /usr/bin/ COPY ./weed /usr/bin/

9
docker/Makefile

@ -20,7 +20,14 @@ build: binary
docker build --no-cache -t chrislusf/seaweedfs:local -f Dockerfile.local . docker build --no-cache -t chrislusf/seaweedfs:local -f Dockerfile.local .
build_e2e: binary_race build_e2e: binary_race
docker build --no-cache -t chrislusf/seaweedfs:e2e -f Dockerfile.e2e .
DOCKER_BUILDKIT=1 docker build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \
-t chrislusf/seaweedfs:e2e \
-f Dockerfile.e2e .
# Move cache to avoid growing cache size
rm -rf /tmp/.buildx-cache || true
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true
go_build: # make go_build tags=elastic,ydb,gocdk,hdfs,5BytesOffset,tarantool go_build: # make go_build tags=elastic,ydb,gocdk,hdfs,5BytesOffset,tarantool
docker build --build-arg TAGS=$(tags) --no-cache -t chrislusf/seaweedfs:go_build -f Dockerfile.go_build . docker build --build-arg TAGS=$(tags) --no-cache -t chrislusf/seaweedfs:go_build -f Dockerfile.go_build .

24
docker/compose/e2e-mount.yml

@ -6,16 +6,20 @@ services:
command: "-v=4 master -ip=master -ip.bind=0.0.0.0 -raftBootstrap" command: "-v=4 master -ip=master -ip.bind=0.0.0.0 -raftBootstrap"
healthcheck: healthcheck:
test: [ "CMD", "curl", "--fail", "-I", "http://localhost:9333/cluster/healthz" ] test: [ "CMD", "curl", "--fail", "-I", "http://localhost:9333/cluster/healthz" ]
interval: 1s
timeout: 60s
interval: 2s
timeout: 10s
retries: 30
start_period: 10s
volume: volume:
image: chrislusf/seaweedfs:e2e image: chrislusf/seaweedfs:e2e
command: "-v=4 volume -mserver=master:9333 -ip=volume -ip.bind=0.0.0.0 -preStopSeconds=1" command: "-v=4 volume -mserver=master:9333 -ip=volume -ip.bind=0.0.0.0 -preStopSeconds=1"
healthcheck: healthcheck:
test: [ "CMD", "curl", "--fail", "-I", "http://localhost:8080/healthz" ] test: [ "CMD", "curl", "--fail", "-I", "http://localhost:8080/healthz" ]
interval: 1s
timeout: 30s
interval: 2s
timeout: 10s
retries: 15
start_period: 5s
depends_on: depends_on:
master: master:
condition: service_healthy condition: service_healthy
@ -25,8 +29,10 @@ services:
command: "-v=4 filer -master=master:9333 -ip=filer -ip.bind=0.0.0.0" command: "-v=4 filer -master=master:9333 -ip=filer -ip.bind=0.0.0.0"
healthcheck: healthcheck:
test: [ "CMD", "curl", "--fail", "-I", "http://localhost:8888" ] test: [ "CMD", "curl", "--fail", "-I", "http://localhost:8888" ]
interval: 1s
timeout: 30s
interval: 2s
timeout: 10s
retries: 15
start_period: 5s
depends_on: depends_on:
volume: volume:
condition: service_healthy condition: service_healthy
@ -46,8 +52,10 @@ services:
memory: 4096m memory: 4096m
healthcheck: healthcheck:
test: [ "CMD", "mountpoint", "-q", "--", "/mnt/seaweedfs" ] test: [ "CMD", "mountpoint", "-q", "--", "/mnt/seaweedfs" ]
interval: 1s
timeout: 30s
interval: 2s
timeout: 10s
retries: 15
start_period: 10s
depends_on: depends_on:
filer: filer:
condition: service_healthy condition: service_healthy
Loading…
Cancel
Save