-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from utopia-php/feat-dockerfile
Dockerfiles
- Loading branch information
Showing
12 changed files
with
1,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build and Push to DockerHub | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: appwrite/utopia-base | ||
TAG: ${{ github.event.release.tag_name }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['8.0', '8.1', '8.2', '8.3'] # add PHP versions as required | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: php-${{ matrix.php-versions }}/. | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:php-${{ matrix.php-versions }}-${{ env.TAG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Test container structure | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: appwrite/base | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['8.0', '8.1', '8.2', '8.3'] # add PHP versions as required | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup container structure test | ||
run: | | ||
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 | ||
chmod +x container-structure-test-linux-amd64 | ||
sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test | ||
- name: Build & run container structure test | ||
run: | | ||
docker build -t utopia-base-test php-${{ matrix.php-versions }}/. | ||
container-structure-test test --image utopia-base-test --config tests.yaml php-${{ matrix.php-versions }}/tests.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Appwrite | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
FROM php:8.0-cli-alpine as compile | ||
|
||
ENV PHP_REDIS_VERSION="6.0.2" \ | ||
PHP_SWOOLE_VERSION="v5.1.2" \ | ||
PHP_IMAGICK_VERSION="3.7.0" \ | ||
PHP_YAML_VERSION="2.2.3" \ | ||
PHP_MAXMINDDB_VERSION="v1.11.1" \ | ||
PHP_SCRYPT_VERSION="2.0.1" \ | ||
PHP_ZSTD_VERSION="0.13.3" \ | ||
PHP_BROTLI_VERSION="0.15.0" \ | ||
PHP_SNAPPY_VERSION="c27f830dcfe6c41eb2619a374de10fd0597f4939" \ | ||
PHP_LZ4_VERSION="2f006c3e4f1fb3a60d2656fc164f9ba26b71e995" \ | ||
PHP_XDEBUG_VERSION="3.3.1" | ||
|
||
RUN \ | ||
apk add --no-cache --virtual .deps \ | ||
linux-headers \ | ||
icu-dev \ | ||
make \ | ||
automake \ | ||
autoconf \ | ||
gcc \ | ||
g++ \ | ||
git \ | ||
zlib-dev \ | ||
openssl-dev \ | ||
yaml-dev \ | ||
imagemagick \ | ||
imagemagick-dev \ | ||
libjpeg-turbo-dev \ | ||
jpeg-dev \ | ||
libjxl-dev \ | ||
libmaxminddb-dev \ | ||
zstd-dev \ | ||
brotli-dev \ | ||
lz4-dev \ | ||
curl-dev | ||
|
||
RUN docker-php-ext-install sockets | ||
|
||
FROM compile AS redis | ||
RUN \ | ||
# Redis Extension | ||
git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git && \ | ||
cd phpredis && \ | ||
phpize && \ | ||
./configure && \ | ||
make && make install | ||
|
||
## Swoole Extension | ||
FROM compile AS swoole | ||
RUN \ | ||
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git && \ | ||
cd swoole-src && \ | ||
phpize && \ | ||
./configure --enable-sockets --enable-http2 --enable-openssl --enable-swoole-curl && \ | ||
make && make install && \ | ||
cd .. | ||
|
||
## Imagick Extension | ||
FROM compile AS imagick | ||
RUN \ | ||
git clone --depth 1 --branch $PHP_IMAGICK_VERSION https://github.com/imagick/imagick && \ | ||
cd imagick && \ | ||
phpize && \ | ||
./configure && \ | ||
make && make install | ||
|
||
## YAML Extension | ||
FROM compile AS yaml | ||
RUN \ | ||
git clone --depth 1 --branch $PHP_YAML_VERSION https://github.com/php/pecl-file_formats-yaml && \ | ||
cd pecl-file_formats-yaml && \ | ||
phpize && \ | ||
./configure && \ | ||
make && make install | ||
|
||
## Maxminddb extension | ||
FROM compile AS maxmind | ||
RUN \ | ||
git clone --depth 1 --branch $PHP_MAXMINDDB_VERSION https://github.com/maxmind/MaxMind-DB-Reader-php.git && \ | ||
cd MaxMind-DB-Reader-php && \ | ||
cd ext && \ | ||
phpize && \ | ||
./configure && \ | ||
make && make install | ||
|
||
# Zstd Compression | ||
FROM compile as zstd | ||
RUN git clone --recursive -n https://github.com/kjdev/php-ext-zstd.git \ | ||
&& cd php-ext-zstd \ | ||
&& git checkout $PHP_ZSTD_VERSION \ | ||
&& phpize \ | ||
&& ./configure --with-libzstd \ | ||
&& make && make install | ||
|
||
## Brotli Extension | ||
FROM compile as brotli | ||
RUN git clone https://github.com/kjdev/php-ext-brotli.git \ | ||
&& cd php-ext-brotli \ | ||
&& git reset --hard $PHP_BROTLI_VERSION \ | ||
&& phpize \ | ||
&& ./configure --with-libbrotli \ | ||
&& make && make install | ||
|
||
## LZ4 Extension | ||
FROM compile AS lz4 | ||
RUN git clone --recursive https://github.com/kjdev/php-ext-lz4.git \ | ||
&& cd php-ext-lz4 \ | ||
&& git reset --hard $PHP_LZ4_VERSION \ | ||
&& phpize \ | ||
&& ./configure --with-lz4-includedir=/usr \ | ||
&& make && make install | ||
|
||
## Snappy Extension | ||
FROM compile AS snappy | ||
RUN git clone --recursive https://github.com/kjdev/php-ext-snappy.git \ | ||
&& cd php-ext-snappy \ | ||
&& git reset --hard $PHP_SNAPPY_VERSION \ | ||
&& phpize \ | ||
&& ./configure \ | ||
&& make && make install | ||
|
||
## Scrypt Extension | ||
FROM compile AS scrypt | ||
RUN git clone --depth 1 https://github.com/DomBlack/php-scrypt.git \ | ||
&& cd php-scrypt \ | ||
&& git reset --hard $PHP_SCRYPT_VERSION \ | ||
&& phpize \ | ||
&& ./configure --enable-scrypt \ | ||
&& make && make install | ||
|
||
## XDebug Extension | ||
FROM compile AS xdebug | ||
RUN \ | ||
git clone --depth 1 --branch $PHP_XDEBUG_VERSION https://github.com/xdebug/xdebug && \ | ||
cd xdebug && \ | ||
phpize && \ | ||
./configure && \ | ||
make && make install | ||
|
||
FROM php:8.0-cli-alpine as final | ||
|
||
LABEL maintainer="team@appwrite.io" | ||
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
RUN \ | ||
apk update \ | ||
&& apk add --no-cache \ | ||
linux-headers \ | ||
rsync \ | ||
brotli-dev \ | ||
lz4-dev \ | ||
zstd-dev \ | ||
yaml-dev \ | ||
imagemagick \ | ||
libjpeg-turbo \ | ||
libjxl \ | ||
libavif \ | ||
libheif \ | ||
# imagemagick-heic \ | ||
libgomp \ | ||
git \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
RUN docker-php-ext-install sockets | ||
|
||
WORKDIR /usr/src/code | ||
|
||
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20200930/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=redis /usr/local/lib/php/extensions/no-debug-non-zts-20200930/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=imagick /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=yaml /usr/local/lib/php/extensions/no-debug-non-zts-20200930/yaml.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=scrypt /usr/local/lib/php/extensions/no-debug-non-zts-20200930/scrypt.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=zstd /usr/local/lib/php/extensions/no-debug-non-zts-20200930/zstd.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=brotli /usr/local/lib/php/extensions/no-debug-non-zts-20200930/brotli.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=lz4 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/lz4.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=snappy /usr/local/lib/php/extensions/no-debug-non-zts-20200930/snappy.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
COPY --from=xdebug /usr/local/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ | ||
|
||
# Enable Extensions | ||
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini | ||
RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini | ||
RUN echo extension=imagick.so >> /usr/local/etc/php/conf.d/imagick.ini | ||
RUN echo extension=yaml.so >> /usr/local/etc/php/conf.d/yaml.ini | ||
RUN echo extension=scrypt.so >> /usr/local/etc/php/conf.d/scrypt.ini | ||
RUN echo extension=zstd.so >> /usr/local/etc/php/conf.d/zstd.ini | ||
RUN echo extension=brotli.so >> /usr/local/etc/php/conf.d/brotli.ini | ||
RUN echo extension=lz4.so >> /usr/local/etc/php/conf.d/lz4.ini | ||
RUN echo extension=snappy.so >> /usr/local/etc/php/conf.d/snappy.ini | ||
|
||
EXPOSE 80 | ||
|
||
CMD [ "tail", "-f", "/dev/null" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
schemaVersion: '2.0.0' | ||
|
||
fileExistenceTests: | ||
## Extension files | ||
- name: 'Check swoole extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/swoole.so | ||
shouldExist: true | ||
- name: 'Check redis extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/redis.so | ||
shouldExist: true | ||
- name: 'Check imagick extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so | ||
shouldExist: true | ||
- name: 'Check yaml extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/yaml.so | ||
shouldExist: true | ||
- name: 'Check scrypt extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/scrypt.so | ||
shouldExist: true | ||
- name: 'Check zstd extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/zstd.so | ||
shouldExist: true | ||
- name: 'Check brotli extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/brotli.so | ||
shouldExist: true | ||
- name: 'Check lz4 extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/lz4.so | ||
shouldExist: true | ||
- name: 'Check snappy extension' | ||
path: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/snappy.so | ||
shouldExist: true |
Oops, something went wrong.