Skip to content

Commit a3ed464

Browse files
committed
Adapt CI command scripts to also support podman
1 parent 1817e9c commit a3ed464

File tree

7 files changed

+45
-18
lines changed

7 files changed

+45
-18
lines changed

scripts/.common.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ YELLOW='\E[1;33m'
1010

1111
export BLUE CYAN GREEN RED RESET YELLOW
1212

13+
# Identify docker-like command
14+
# Ensure docker exists
15+
if command -v docker 1>/dev/null 2>&1; then
16+
export docker=docker
17+
elif command -v podman 1>/dev/null 2>&1; then
18+
export docker=podman
19+
else
20+
echo -e "${RED}❯ docker or podman command is not available${RESET}"
21+
exit 1
22+
fi
23+
1324
# Docker Compose
1425
COMPOSE_PROJECT_NAME="npmdev"
1526
COMPOSE_FILE="docker/docker-compose.dev.yml"

scripts/buildx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ if [ "$BUILD_COMMIT" == "" ]; then
1414
fi
1515

1616
# Buildx Builder
17-
docker buildx create --name "${BUILDX_NAME:-npm}" || echo
18-
docker buildx use "${BUILDX_NAME:-npm}"
17+
$docker buildx create --name "${BUILDX_NAME:-npm}" || echo
18+
$docker buildx use "${BUILDX_NAME:-npm}"
1919

20-
docker buildx build \
20+
$docker buildx build \
2121
--build-arg BUILD_VERSION="${BUILD_VERSION:-dev}" \
2222
--build-arg BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
2323
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \
@@ -31,6 +31,6 @@ docker buildx build \
3131
.
3232

3333
rc=$?
34-
docker buildx rm "${BUILDX_NAME:-npm}"
34+
$docker buildx rm "${BUILDX_NAME:-npm}"
3535
echo -e "${BLUE}${GREEN}Multiarch build Complete${RESET}"
3636
exit $rc

scripts/ci/frontend-build

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
DOCKER_IMAGE=jc21/nginx-full:certbot-node
77

88
# Ensure docker exists
9-
if hash docker 2>/dev/null; then
10-
docker pull "${DOCKER_IMAGE}"
11-
cd "${DIR}/../.."
12-
echo -e "${BLUE}${CYAN}Building Frontend ...${RESET}"
13-
docker run --rm -e CI=true -v "$(pwd)/frontend:/app/frontend" -v "$(pwd)/global:/app/global" -w /app/frontend "$DOCKER_IMAGE" sh -c "yarn install && yarn build && yarn build && chown -R $(id -u):$(id -g) /app/frontend"
14-
echo -e "${BLUE}${GREEN}Building Frontend Complete${RESET}"
9+
if command -v docker 1>/dev/null 2>&1; then
10+
docker=docker
11+
elif command -v podman 1>/dev/null 2>&1; then
12+
docker=podman
1513
else
16-
echo -e "${RED}❯ docker command is not available${RESET}"
14+
echo -e "${RED}❯ docker or podman command is not available${RESET}"
15+
exit 1
1716
fi
17+
18+
$docker pull "${DOCKER_IMAGE}"
19+
cd "${DIR}/../.."
20+
echo -e "${BLUE}${CYAN}Building Frontend ...${RESET}"
21+
$docker run --rm -e CI=true -v "$(pwd)/frontend:/app/frontend" -v "$(pwd)/global:/app/global" -w /app/frontend "$DOCKER_IMAGE" sh -c "yarn install && yarn build && yarn build && chown -R $(id -u):$(id -g) /app/frontend"
22+
echo -e "${BLUE}${GREEN}Building Frontend Complete${RESET}"

scripts/ci/test-and-build

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
#!/bin/bash -e
22

33
DOCKER_IMAGE=jc21/nginx-full:certbot-node
4-
docker pull "${DOCKER_IMAGE}"
4+
5+
# Ensure docker exists
6+
if command -v docker 1>/dev/null 2>&1; then
7+
docker=docker
8+
elif command -v podman 1>/dev/null 2>&1; then
9+
docker=podman
10+
else
11+
echo -e "${RED}❯ docker or podman command is not available${RESET}"
12+
exit 1
13+
fi
14+
15+
$docker pull "${DOCKER_IMAGE}"
516

617
# Test
7-
docker run --rm \
18+
$docker run --rm \
819
-v "$(pwd)/backend:/app" \
920
-v "$(pwd)/global:/app/global" \
1021
-w /app \
1122
"${DOCKER_IMAGE}" \
1223
sh -c 'yarn install && yarn eslint . && rm -rf node_modules'
1324

1425
# Build
15-
docker build --pull --no-cache --squash --compress \
26+
$docker build --pull --no-cache --squash --compress \
1627
-t "${IMAGE}:ci-${BUILD_NUMBER}" \
1728
-f docker/Dockerfile \
1829
--build-arg TARGETPLATFORM=linux/amd64 \

scripts/docs-build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77
if hash docker 2>/dev/null; then
88
cd "${DIR}/.."
99
echo -e "${BLUE}${CYAN}Building Docs ...${RESET}"
10-
docker run --rm -e CI=true -v "$(pwd)/docs:/app/docs" -w /app/docs node:alpine sh -c "yarn install && yarn build && chown -R $(id -u):$(id -g) /app/docs"
10+
$docker run --rm -e CI=true -v "$(pwd)/docs:/app/docs" -w /app/docs node:alpine sh -c "yarn install && yarn build && chown -R $(id -u):$(id -g) /app/docs"
1111
echo -e "${BLUE}${GREEN}Building Docs Complete${RESET}"
1212
else
1313
echo -e "${RED}❯ docker command is not available${RESET}"

scripts/start-dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if hash docker-compose 2>/dev/null; then
1818

1919
if [ "$1" == "-f" ]; then
2020
echo -e "${BLUE}${YELLOW}Following Backend Container:${RESET}"
21-
docker logs -f npm_core
21+
$docker logs -f npm_core
2222
else
2323
echo -e "${YELLOW}Hint:${RESET} You can follow the output of some of the containers with:"
24-
echo " docker logs -f npm_core"
24+
echo " $docker logs -f npm_core"
2525
fi
2626
else
2727
echo -e "${RED}❯ docker-compose command is not available${RESET}"

scripts/wait-healthy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ echo -e "${BLUE}❯ ${CYAN}Waiting for healthy: ${YELLOW}${SERVICE}${RESET}"
1919
until [ "${HEALTHY}" = "healthy" ]; do
2020
echo -n "."
2121
sleep 1
22-
HEALTHY="$(docker inspect -f '{{.State.Health.Status}}' $SERVICE)"
22+
HEALTHY="$($docker inspect -f '{{.State.Health.Status}}' $SERVICE)"
2323
((LOOPCOUNT++))
2424

2525
if [ "$LOOPCOUNT" == "$LIMIT" ]; then

0 commit comments

Comments
 (0)