Skip to content

Commit

Permalink
fix(docker): build image locally and on CI (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Sep 29, 2022
1 parent f950b22 commit b51386f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
dry_run:
required: true
type: boolean
default: 'true'
default: true
description: 'DryRun?'

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
dry_run:
required: true
type: boolean
default: 'true'
default: true
description: 'DryRun?'

env:
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------
# Build playwright
# ------------------
FROM ubuntu:focal as base
FROM ubuntu:jammy as base

# For tzdata
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -25,9 +25,10 @@ RUN apt-get update && \
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright

# Browsers will be downloaded in `/ms-playwright`.
# !!! MAKE SURE THE PLAYWRIGHT VERSION MATCHES THE ONE IN package.json
RUN mkdir /ms-playwright \
&& npx playwright install chromium \
&& npx playwright install-deps chromium \
&& npx playwright@1.26.1 install chromium \
&& npx playwright@1.26.1 install-deps chromium \
# Clean cache
&& rm -rf /var/lib/apt/lists/* \
&& chmod -R 777 /ms-playwright
Expand All @@ -36,7 +37,7 @@ RUN mkdir /ms-playwright \
# ------------------
# package.json cache
# ------------------
FROM apteno/alpine-jq:2022-03-27 AS deps
FROM apteno/alpine-jq:2022-09-25 AS deps

# To prevent cache invalidation from changes in fields other than dependencies
COPY package.json /tmp
Expand Down
6 changes: 5 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ echo ""

# Build renderscript

# To run locally on your mac m1, you need to change platform to linux/arm64/v8
# For deploy, it should be linux/amd64
docker buildx build \
--platform linux/arm64/v8,linux/amd64 \
--platform linux/amd64 \
--progress plain \
-t algolia/renderscript \
-t "algolia/renderscript:${current}" \
-t "algolia/renderscript:${hash}" \
-t "algolia/renderscript:latest" \
--build-arg "VERSION=${current}" \
--load \
.
15 changes: 10 additions & 5 deletions scripts/test_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ set -e
hash=$1 # the last commit change because of semantic-release
docker run -d --name renderscript_test -p 3000:3000 algolia/renderscript:$hash

echo "waiting for docker"
sleepSec=20
sleep $sleepSec

echo "slept for ${sleepSec}s"
ATTEMPTS=10
until $(curl -o /dev/null -s -f http://localhost:3000/ready); do
echo "waiting for docker..."
sleep 1
((ATTEMPTS=ATTEMPTS-1))
if [[ $ATTEMPTS -eq "0" ]]; then
echo "Timed out, check the logs of renderscript_test container"
exit 1
fi
done

logs=$(docker logs renderscript_test 2>&1)
echo $logs
Expand Down

0 comments on commit b51386f

Please sign in to comment.