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

GitHub actions docker ci #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions .devops/ci.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
###############################################################################
FROM alpine as build

RUN apk update && \
apk add make

WORKDIR /build
COPY . .

RUN make cosmocc

RUN make -j $(nproc)

###############################################################################
FROM alpine as package

WORKDIR /package

COPY --from=build /build/o/llama.cpp/main/main ./llamafile
COPY --from=build /build/o/llamafile/zipalign ./zipalign
COPY --from=build /build/models/TinyLLama-v0.1-5M-F16.gguf ./model.gguf

RUN echo "-m" > .args
RUN echo "model.gguf" >> .args
RUN ./zipalign -j0 llamafile model.gguf .args

RUN chmod +x ./llamafile

###############################################################################
FROM alpine as final

WORKDIR /usr/src/app

COPY --from=package /package/llamafile ./llamafile

RUN ./llamafile -e -p '## Famous Speech\n\nFour score and seven' -n 50 -ngl 0

ENTRYPOINT ["/bin/sh", "/usr/src/app/llamafile"]
CMD ["--cli", "-p", "hello world the gruff man said"]

## Just running test?
# docker build -f .devops/ci.Dockerfile -t llamafile_ci .
# docker run llamafile_ci

## Get the binary?
# 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


33 changes: 33 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions build/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading