Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for Arm Mac #194

Merged
merged 17 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FDB_VER=6.2.30
FDB_LIB_URL=https://github.com/apple/foundationdb/releases/download/6.2.30/foundationdb-clients-6.2.30-1.el7.x86_64.rpm
FDB_LIB_URL=https://github.com/apple/foundationdb/releases/download/6.2.30/foundationdb-clients_6.2.30-1_amd64.deb
FDB_DOCKER_IMAGE=foundationdb/foundationdb:6.2.30
GO_URL=https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
GOLANGCI_LINT_VER=v1.49.0
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
build:
strategy:
matrix:
fdb_ver: [6.2.30, 7.1.33]
fdb_ver: [6.2.30, 7.1.61]
include:
- fdb_ver: 6.2.30
fdb_lib_url: https://github.com/apple/foundationdb/releases/download/6.2.30/foundationdb-clients-6.2.30-1.el7.x86_64.rpm
fdb_lib_url: https://github.com/apple/foundationdb/releases/download/6.2.30/foundationdb-clients_6.2.30-1_amd64.deb
fdb_docker_image: foundationdb/foundationdb:6.2.30
- fdb_ver: 7.1.33
fdb_lib_url: https://github.com/apple/foundationdb/releases/download/7.1.33/foundationdb-clients-7.1.33-1.el7.x86_64.rpm
fdb_docker_image: foundationdb/foundationdb:7.1.33
- fdb_ver: 7.1.61
fdb_lib_url: https://github.com/apple/foundationdb/releases/download/7.1.61/foundationdb-clients_7.1.61-1_amd64.deb
fdb_docker_image: foundationdb/foundationdb:7.1.61
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function join_array {
function escape_quotes {
out=()
for arg in "$@"; do
# shellcheck disable=SC1003
out+=("$(printf "'%s'" "${arg//'/\\'}")")
done
echo "${out[@]}"
Expand Down Expand Up @@ -175,6 +176,11 @@ while [[ $# -gt 0 ]]; do
shift 2
;;

--no-hado)
NO_HADO="x"
shift 1
;;

--help)
print_help
exit 0
Expand Down Expand Up @@ -202,7 +208,7 @@ fi

if [[ -n "$VERIFY_CODEBASE" ]]; then
BUILD_TASKS+=('./scripts/setup_database.sh')
BUILD_TASKS+=('./scripts/verify_codebase.sh')
BUILD_TASKS+=("./scripts/verify_codebase.sh ${NO_HADO:+--no-hado}")
fi

BUILD_COMMAND="$(join_array ' && ' "${BUILD_TASKS[@]}")"
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
version: "3.9"
services:

# The build service is responsible for building,
# linting, and testing the code.
build:
container_name: "build"
image: "docker.io/janderland/fdbq-build:${DOCKER_TAG}"
platform: "linux/amd64"
build:
context: "./docker"
target: "builder"
platforms:
- "linux/amd64"
args:
FDB_LIB_URL: "${FDB_LIB_URL}"
GO_URL: "${GO_URL}"
Expand All @@ -30,9 +32,12 @@ services:
fdbq:
container_name: "fdbq"
image: "docker.io/janderland/fdbq:${DOCKER_TAG}"
platform: "linux/amd64"
build:
context: "."
dockerfile: "./docker/Dockerfile"
platforms:
- "linux/amd64"
args:
FDBQ_VER: "${DOCKER_TAG}"
FDB_LIB_URL: "${FDB_LIB_URL}"
Expand All @@ -50,5 +55,6 @@ services:
fdb:
container_name: "fdb"
image: "${FDB_DOCKER_IMAGE}"
platform: "linux/amd64"
ports:
- "4500:4500"
35 changes: 22 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# 'builder' includes all build & testing dependencies.
FROM centos:7 AS builder
FROM debian:12 AS builder

RUN yum -y --setopt=skip_missing_names_on_install=False install epel-release gcc-4.8.5 &&\
yum -y --setopt=skip_missing_names_on_install=False install ShellCheck-0.3.8 &&\
yum -y --setopt=skip_missing_names_on_install=False install git-1.8.3.1 &&\
yum -y clean all
RUN apt-get update &&\
apt-get install --no-install-recommends -y \
build-essential=12.9 \
ca-certificates=20230311 \
shellcheck=0.9.0-1 \
git=1:2.39.2-1.1 \
curl=7.88.1-10+deb12u6 &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

ARG FDB_LIB_URL
RUN curl -Lo fdb.rpm $FDB_LIB_URL &&\
rpm -i ./fdb.rpm &&\
rm ./fdb.rpm
RUN curl -Lo /fdb.deb $FDB_LIB_URL &&\
dpkg -i /fdb.deb

ARG GO_URL
RUN curl -Lo go.tar.gz $GO_URL &&\
Expand All @@ -34,6 +38,12 @@ ARG JQ_URL
RUN curl -Lo /usr/local/bin/jq $JQ_URL &&\
chmod +x /usr/local/bin/jq

# Configure git so it allows any user to run git commands
# on the /fdbq directory. This allows the user which runs
# CI to be different from the user which built the Docker
# image.
RUN git config --global --add safe.directory /fdbq


# 'gobuild' executes 'go build'.
FROM builder AS gobuild
Expand All @@ -46,12 +56,11 @@ RUN go build -o /fdbq -ldflags="-X 'github.com/janderland/fdbq/internal/app.Vers


# The final stage builds the 'fdbq' image.
FROM centos:7
FROM debian:12

ARG FDB_LIB_URL
RUN curl -Lo fdb.rpm $FDB_LIB_URL &&\
rpm -i ./fdb.rpm &&\
rm ./fdb.rpm
COPY --from=gobuild /fdb.deb /fdb.deb
RUN dpkg -i ./fdb.deb &&\
rm /fdb.deb

ENV TERM="xterm-256color"

Expand Down
8 changes: 5 additions & 3 deletions scripts/verify_codebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ set -x
# Lint shell scripts.
find . -type f -iname '*.sh' -print0 | xargs -t -0 shellcheck

# Lint Dockerfiles.
find . -type f -iname 'Dockerfile' -print0 | xargs -t -0 -n 1 hadolint
# Lint Dockerfiles, if the '--no-hado' flag wasn't passed.
if [[ "${1:-}" != '--no-hado' ]]; then
find . -type f -iname 'Dockerfile' -print0 | xargs -t -0 -n 1 hadolint
fi

# build, lint, & test Go code.
# Build, lint, & test Go code.
go build ./...
golangci-lint run ./...
go test ./...
Loading