Skip to content

Commit 2ca4f5b

Browse files
committed
Adds docker image build
1 parent 593d91a commit 2ca4f5b

File tree

6 files changed

+152
-4
lines changed

6 files changed

+152
-4
lines changed

.docker/Dockerfile

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
ARG ROAD_RUNNER_IMAGE=2024.2.0
2+
ARG DOLT_IMAGE=1.42.8
3+
4+
# Build dolt binary
5+
FROM dolthub/dolt:$DOLT_IMAGE as dolt
6+
# Build rr binary
7+
FROM ghcr.io/roadrunner-server/roadrunner:$ROAD_RUNNER_IMAGE as rr
8+
# Clone the project
9+
FROM alpine/git as git
10+
11+
ARG REPOSITORY=https://github.com/llm-agents-php/sample-app.git
12+
ARG BRANCH=main
13+
RUN git clone -b $BRANCH $REPOSITORY /app
14+
15+
FROM php:8.3-cli-alpine3.18
16+
17+
RUN apk add --no-cache $PHPIZE_DEPS \
18+
curl \
19+
libcurl \
20+
wget \
21+
libzip-dev \
22+
libmcrypt-dev \
23+
libxslt-dev \
24+
libxml2-dev \
25+
openssl-dev \
26+
icu-dev \
27+
zip \
28+
unzip \
29+
linux-headers
30+
31+
RUN docker-php-ext-install \
32+
opcache \
33+
zip \
34+
dom \
35+
sockets
36+
37+
# PDO database drivers support
38+
RUN docker-php-ext-install pdo_mysql
39+
40+
COPY --from=git /app /app
41+
COPY --from=rr /usr/bin/rr /app
42+
COPY --from=dolt /usr/local/bin/dolt /app
43+
COPY --from=composer /usr/bin/composer /usr/bin/composer
44+
45+
ARG APP_VERSION=v1.0
46+
ENV COMPOSER_ALLOW_SUPERUSER=1
47+
48+
WORKDIR /app
49+
50+
RUN composer config --no-plugins allow-plugins.spiral/composer-publish-plugin false
51+
RUN composer install --no-dev
52+
53+
WORKDIR /app
54+
55+
RUN mkdir .db
56+
RUN ./dolt --data-dir=.db sql -q "create database llm;"
57+
58+
ENV APP_ENV=prod
59+
ENV DEBUG=false
60+
ENV VERBOSITY_LEVEL=verbose
61+
ENV ENCRYPTER_KEY=def00000232ae92c8e8ec0699093fa06ce014cd48d39c3c62c279dd947db084e56ee48b5c91cebc1c5abe53f7755021d09043757561c244c1c0c765cfeb5db33eb45a903
62+
ENV MONOLOG_DEFAULT_CHANNEL=roadrunner
63+
ENV MONOLOG_DEFAULT_LEVEL=INFO
64+
ENV APP_VERSION=$APP_VERSION
65+
ENV RR_LOG_LEVEL=error
66+
67+
LABEL org.opencontainers.image.source=$REPOSITORY
68+
LABEL org.opencontainers.image.description="LL Agents PHP"
69+
LABEL org.opencontainers.image.licenses=MIT
70+
71+
CMD ./rr serve -c .rr.yaml

.github/FUNDING.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
patreon: butschster

.github/workflows/docker-image.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Docker Image CI
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build-release:
10+
if: "!github.event.release.prerelease"
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: 'Get Previous tag'
17+
id: previoustag
18+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
19+
with:
20+
fallback: v0.1
21+
22+
- name: Login to Docker Hub
23+
uses: docker/login-action@v2
24+
with:
25+
registry: ghcr.io
26+
username: ${{ secrets.GHCR_LOGIN }}
27+
password: ${{ secrets.GHCR_PASSWORD }}
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v2
31+
32+
- name: Set up Docker Buildx
33+
id: buildx
34+
uses: docker/setup-buildx-action@v2
35+
36+
- name: Build and push
37+
id: docker_build
38+
uses: docker/build-push-action@v3
39+
with:
40+
context: ./
41+
platforms: linux/amd64,linux/arm64
42+
file: ./.docker/Dockerfile
43+
push: true
44+
build-args: |
45+
APP_VERSION=${{ steps.previoustag.outputs.tag }}
46+
tags:
47+
ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.previoustag.outputs.tag }}

.rr.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ kv:
1010

1111
server:
1212
on_init:
13-
command: 'php app.php migrate'
13+
command: 'php app.php migrate --force'
1414
command: 'php app.php'
1515
relay: pipes
1616

Makefile

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
###########################
2+
# Docker #
3+
###########################
4+
start:
5+
docker compose up --remove-orphans -d;
6+
7+
up: start
8+
9+
stop:
10+
docker compose stop;
11+
12+
down:
13+
docker compose down;
14+
15+
restart:
16+
docker compose restart;
17+
18+
bash:
19+
docker compose exec app /bin/sh;
20+
21+
###########################
22+
# Local development #
23+
###########################
124
init: init-db init-rr
225

326
# Install dolt database
@@ -21,6 +44,3 @@ init-rr:
2144

2245
clear-cache:
2346
rm -rf runtime/cache;
24-
25-
start:
26-
./rr serve

docker-compose.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.7'
2+
3+
services:
4+
app:
5+
build: "./.docker"
6+
environment:
7+
OPENAI_KEY: ${OPENAI_KEY}

0 commit comments

Comments
 (0)