diff --git a/.devops/ci.Dockerfile b/.devops/ci.Dockerfile index b43d4431c6..c1965408e0 100644 --- a/.devops/ci.Dockerfile +++ b/.devops/ci.Dockerfile @@ -1,4 +1,3 @@ - ############################################################################### FROM alpine as build @@ -8,7 +7,9 @@ RUN apk update && \ WORKDIR /build COPY . . -RUN make +RUN make cosmocc + +RUN make -j $(nproc) ############################################################################### FROM alpine as package @@ -45,3 +46,5 @@ CMD ["--cli", "-p", "hello world the gruff man said"] # docker build -f .devops/ci.Dockerfile -t llamafile_ci . # docker create --name llamafile_ci_container llamafile_ci # docker cp llamafile_ci_container:/usr/src/app/llamafile test.llamafile + + diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..2208c68912 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,33 @@ +name: docker-ci +on: + push: + branches: [ master, main, fix ] + pull_request: + branches: [ master, main, fix ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build Docker image + run: | + docker build -f .devops/ci.Dockerfile -t llamafile_ci . + + - name: Run Docker container + run: | + docker run llamafile_ci diff --git a/build/config.mk b/build/config.mk index 389e128bdd..acd11939d2 100644 --- a/build/config.mk +++ b/build/config.mk @@ -5,11 +5,16 @@ PREFIX = /usr/local COSMOCC = .cosmocc/3.3.8 TOOLCHAIN = $(COSMOCC)/bin/cosmo +ARCH := $(shell uname -m) + +# Use APE loader to improve portability in container enviroments +APE_LOADER := $(COSMOCC)/bin/ape-$(ARCH).elf + AR = $(TOOLCHAIN)ar CC = $(TOOLCHAIN)cc CXX = $(TOOLCHAIN)c++ -ZIPOBJ = $(COSMOCC)/bin/zipobj -MKDEPS = $(COSMOCC)/bin/mkdeps +ZIPOBJ = $(APE_LOADER) $(COSMOCC)/bin/zipobj +MKDEPS = $(APE_LOADER) $(COSMOCC)/bin/mkdeps INSTALL = install ARFLAGS = rcsD