Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #432 from tmatsuo/ubuntu
Browse files Browse the repository at this point in the history
Build deb packages for ubuntu 16.04
  • Loading branch information
Takashi Matsuo authored Apr 24, 2018
2 parents fdbfdc0 + 0f35099 commit a41e47a
Show file tree
Hide file tree
Showing 398 changed files with 6,571 additions and 0 deletions.
116 changes: 116 additions & 0 deletions ubuntu-package-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Dockerfile used to build php binaries.
# Example usage:
# docker run -v /mydir:/workspace deb-package-builder 5.6.29-1,7.0.14-2
# Then you'll get deb packages in /mydir.

FROM gcr.io/gcp-runtimes/ubuntu_16_0_4

ENV PHP_DIR=/opt/php \
PATH=/opt/php/bin:$PATH

# Need to install debian packaging tools etc
RUN apt-get update -y && \
apt-get install -y -q --no-install-recommends \
# Tools
git \
# PHP deps
curl \
libcurl3-gnutls \
gettext \
libbz2-1.0 \
libgmp10 \
libicu55 \
libjpeg-turbo8 \
liblua5.3-0 \
libmcrypt4 \
libmemcached11 \
libmemcachedutil2 \
libpcre3 \
libpng12-0 \
libpq5 \
libreadline6 \
librecode0 \
libsasl2-modules \
libsqlite3-0 \
libxml2 \
libxslt1.1 \
sasl2-bin \
zlib1g \
# debian packages
debhelper \
devscripts \
libparse-debcontrol-perl \
# headers
libbz2-dev \
libcurl4-gnutls-dev \
libfreetype6-dev \
libgettextpo-dev \
libgmp-dev \
libuv1-dev \
libicu-dev \
libjpeg-turbo8-dev \
libjson-c-dev \
liblua5.3-dev \
libmagick++-dev \
libmcrypt-dev \
libmemcached-dev \
libpcre3-dev \
libpng-dev \
libpq-dev \
libreadline6-dev \
librecode-dev \
libsasl2-dev \
libsqlite3-dev \
libsodium-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
# build tools
build-essential \
autoconf \
bison \
file \
g++ \
gcc \
libc-dev \
make \
patch \
pkg-config \
re2c \
binutils \
# build tools for cassandra
cmake \
dh-exec \
lsb-release \
fakeroot \
libtool \
automake \
autotools-dev

COPY build.sh /
RUN chmod 0755 /build.sh
RUN mkdir -p /workspace
WORKDIR /workspace

# COPY debian /workspace/debian
# COPY extensions /workspace/extensions
# COPY functions.sh /workspace/functions.sh
# COPY libraries /workspace/libraries
# COPY gpgkeys /workspace/gpgkeys

ENTRYPOINT ["/build.sh"]
109 changes: 109 additions & 0 deletions ubuntu-package-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Debian Package Builder

This directory contains the code to build all of our debian packages for php and extensions.

## PHP Versions

We currently support the latest patch version of 5.6, 7.0, 7.1, and 7.2. See
[releases](https://github.com/GoogleCloudPlatform/php-docker/releases) for exact versions.

## Extensions

* amqp
* apcu
* apcu_bc
* apm (7.0+)
* couchbase (7.0+)
* ds (7.0+)
* eio
* ev
* event
* gprc
* hprose
* imagick
* jsonc
* jsond
* krb5
* libsodium (7.0, 7.1)
* lua (7.0+)
* LZF
* mailparse
* memcache
* memcached
* memprof
* mongo [deprecated] (5.6)
* mongodb
* oauth
* opencensus
* phalcon
* pq
* raphf
* rdkafka
* redis
* SeasLog
* stackdriver_debugger
* stomp
* suhosin
* swoole
* sync
* tcpwrap
* timezonedb
* v8js (7.0+)
* vips (7.0+)
* yaconf (7.0+)
* yaf
* yaml

## Building Packages

1. Install `gcloud` utils.
2. `GOOGLE_PROJECT_ID=my_project_id ./build_packages.sh`

This will use Google Cloud Container Builder to compile packages using docker. The compiled .deb files will be
uploaded to the bucket named `$BUCKET` (defaults to the project id).

If you want to build for specific versions of PHP, set the `$PHP_VERSIONS` environment variable to a comma separated list
of PHP versions. This defaults to a hard-coded list defined in the `build_packages.sh` file

## Adding New Extensions

This folder contains a `new_extension.sh` script to generate the skeleton for
adding support for a new extension.

Example:

```bash
$ ./new_extension.sh
Usage: new_extension.sh <extension name> <upstream maintainer name> <upstream homepage> <package maintainer>

$ ./new_extension.sh grpc "Stanley Cheung <[email protected]>" http://pecl.php.net/package/grpc "Jeff Ching <[email protected]>"
```

This will generate a folder `extensions/grpc` with the following directory
structure:

```
grpc/
|--- debian/
| |--- compat
| |--- control.in
| |--- copyright
| |--- ext-grpc.ini
| |--- gcp-php-grpc.install.in
| |--- rules.in
|--- build.sh
```

The `build.sh` script is the entrypoint for generating the `.deb` package file
and the `debian` folder contains the necessary packaging configuration.

If the extension requires a development dependency, be sure to add an
`apt-get install -y <dev dependency>` to the `build.sh` file. If the extension
requires a runtime dependency, be sure to add it to the `control.in` file.

You may need to update the license section of the `debian/copyright` file to
match the license of the PHP extension.

You may also need to modify the `build.sh` file to skip builds for unsupported
PHP versions (see libsodium for an example) or to specify an older version (see
mailparse for an example).
47 changes: 47 additions & 0 deletions ubuntu-package-builder/build-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
steps:
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/deb-package-builder', '.']
waitFor: ['-']
id: deb-package-builder

# create local directories for the rsync
- name: gcr.io/google-appengine/debian8
args: ['mkdir', '-p', '/workspace/pkg/libraries', '/workspace/pkg/${_PHP_VERSION}']
waitFor: ['-']
id: artifact-dirs

# create gs folders if necessary or rsync fails
- name: gcr.io/cloud-builders/gsutil
args: ['cp', '/workspace/pkg/.gitkeep', 'gs://${_BUCKET}/ubuntu-packages/libraries/']
waitFor: ['-']
id: ensure-libraries-folder
- name: gcr.io/cloud-builders/gsutil
args: ['cp', '/workspace/pkg/.gitkeep', 'gs://${_BUCKET}/ubuntu-packages/${_PHP_VERSION}/']
waitFor: ['-']
id: ensure-packages-folder

# rsync already created packages so we don't rebuild
- name: gcr.io/cloud-builders/gsutil
args: ['-m', 'rsync', 'gs://${_BUCKET}/ubuntu-packages/libraries', '/workspace/pkg/libraries']
waitFor: ['artifact-dirs', 'ensure-libraries-folder']
id: import-libraries
- name: gcr.io/cloud-builders/gsutil
args: ['-m', 'rsync', 'gs://${_BUCKET}/ubuntu-packages/${_PHP_VERSION}', '/workspace/pkg/${_PHP_VERSION}']
waitFor: ['artifact-dirs', 'ensure-packages-folder']
id: import-packages

# build the packages
- name: gcr.io/${_GOOGLE_PROJECT_ID}/deb-package-builder
args: ['${_PHP_VERSION}']
waitFor: ['deb-package-builder', 'import-libraries', 'import-packages']
id: package-build

# export artifacts to gs
- name: gcr.io/cloud-builders/gsutil
args: ['-m', 'rsync', '/workspace/pkg/libraries/', 'gs://${_BUCKET}/ubuntu-packages/libraries/']
waitFor: ['package-build']
id: 'export-libraries'
- name: gcr.io/cloud-builders/gsutil
args: ['-m', 'rsync', '/workspace/pkg/${_PHP_VERSION}/', 'gs://${_BUCKET}/ubuntu-packages/${_PHP_VERSION}/']
waitFor: ['package-build']
id: 'export-packages'
Loading

0 comments on commit a41e47a

Please sign in to comment.