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

Added docker build scripts for alpine and ubuntu #151

Open
wants to merge 2 commits into
base: master
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
37 changes: 37 additions & 0 deletions docker-build/Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ARG VERSION=latest
FROM alpine:${VERSION} AS build

# add c build tools
RUN apk add build-base

# add git
RUN apk add git

# add php dev
RUN apk add php7-dev

# add zlib dev
RUN apk add zlib-dev

# clone php-spx
RUN git clone https://github.com/NoiseByNorthwest/php-spx.git

# set workdir
WORKDIR /php-spx

# checkout release
RUN git checkout tags/v0.4.10

# build php-spx
RUN phpize
RUN ./configure
RUN make

# start again with a new image
FROM scratch

# get version
ARG VERSION

# copy spx module from alpine image to the scratch image so files can be copied back to host
COPY --from=build /php-spx/modules/spx.so alpine-$VERSION/spx.so
42 changes: 42 additions & 0 deletions docker-build/Dockerfile-ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG VERSION=latest
FROM ubuntu:${VERSION} AS build

# https://dev.to/setevoy/docker-configure-tzdata-and-timezone-during-build-20bk
ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# update system
RUN apt update
RUN apt upgrade -y

# install git
RUN apt install -y git

# install php development tools
RUN apt install -y php-dev

# install zlib development tools
RUN apt install -y zlib1g-dev

# clone php-spx
RUN git clone https://github.com/NoiseByNorthwest/php-spx.git

# set workdir
WORKDIR /php-spx

# checkout release
RUN git checkout tags/v0.4.10

# build php-spx
RUN phpize
RUN ./configure
RUN make

# start again with a new image
FROM scratch

# get version
ARG VERSION

# copy spx module from ubuntu image to the scratch image so files can be copied back to host
COPY --from=build /php-spx/modules/spx.so ubuntu-$VERSION/spx.so
8 changes: 8 additions & 0 deletions docker-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# build for ubuntu 20.04
DOCKER_BUILDKIT=1 docker build --file Dockerfile-ubuntu --build-arg "VERSION=20.04" --output type=local,dest=lib .

# build for ubuntu 18.04
DOCKER_BUILDKIT=1 docker build --file Dockerfile-ubuntu --build-arg "VERSION=18.04" --output type=local,dest=lib .

# build for alpine 3.14.0
DOCKER_BUILDKIT=1 docker build --file Dockerfile-alpine --build-arg "VERSION=3.14.0" --output type=local,dest=lib .
Binary file added docker-build/lib/alpine-3.12.1/spx.so
Binary file not shown.
Binary file added docker-build/lib/ubuntu-18.04/spx.so
Binary file not shown.
Binary file added docker-build/lib/ubuntu-20.04/spx.so
Binary file not shown.