Skip to content

Commit 3468c99

Browse files
authored
Merge pull request #1273 from sillsdev/chore/base-php-image-for-lf
Establish a base-php published image to speed up CI builds - created a base-php build and publish workflow - moved lines from base-app into it's own Dockerfile for separate building/publishing
2 parents 453a09a + d5fcfa2 commit 3468c99

3 files changed

Lines changed: 75 additions & 48 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build and publish a base PHP image for LF
2+
3+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
4+
on:
5+
workflow_dispatch:
6+
7+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
8+
jobs:
9+
build-n-publish:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
IMAGE: sillsdev/web-languageforge:base-php
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Build and tag base image
19+
run: docker build -t ${{ env.IMAGE }} -f docker/base-php/Dockerfile .
20+
21+
- name: Log in to Docker Hub
22+
uses: docker/login-action@v1
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
26+
27+
- name: Publish image
28+
run: |
29+
docker push ${{ env.IMAGE }}

docker/app/Dockerfile

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,69 +38,24 @@ FROM ${ENVIRONMENT}-ui-builder AS ui-builder
3838
# artifacts built to /data/src/dist
3939
RUN npm run build:${NPM_BUILD_SUFFIX}
4040

41-
# APP-BASE
42-
FROM php:7.3.28-apache AS base-app
43-
44-
# install apt packages
45-
# p7zip-full - used by LF application for unzipping lexicon uploads
46-
# unzip - used by LF application for unzipping lexicon uploads
47-
# gnupg2 - necessary for LFMerge package installation via SIL sources (will be uninstalled in production)
48-
# curl - used by LF application
49-
RUN apt-get update && apt-get -y install p7zip-full unzip gnupg2 curl && rm -rf /var/lib/apt/lists/*
50-
51-
# see https://github.com/mlocati/docker-php-extension-installer
52-
# PHP extensions required by the LF application
53-
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
54-
RUN install-php-extensions gd mongodb intl
55-
56-
# install and configure LFMerge
57-
# LFMerge required apt packages
58-
# python - required by Mercurial (written in Python), which is bundled in the LFMerge apt package
59-
# lfmerge - main package, from SIL sources
60-
# rsyslog - lfmerge logs to rsyslog and expects this to exist
61-
# logrotate - TODO: is this required?
62-
# iputils-ping - Chorus (part of LFMerge) requires the "ping" command to be available on the command line
63-
RUN curl -L http://linux.lsdev.sil.org/downloads/sil-testing.gpg | apt-key add - \
64-
&& echo "deb http://linux.lsdev.sil.org/ubuntu bionic main" > /etc/apt/sources.list.d/linux-lsdev-sil-org.list \
65-
&& apt-get update \
66-
&& apt-get install --yes --no-install-recommends python lfmerge rsyslog logrotate iputils-ping \
67-
&& rm -rf /var/lib/apt/lists/*
68-
COPY docker/app/lfmerge.conf /etc/languageforge/conf/sendreceive.conf
69-
COPY docker/app/lfmergeqm-background.sh /
70-
RUN adduser www-data fieldworks \
71-
&& chown -R www-data:www-data /var/lib/languageforge \
72-
&& chmod 0755 /var/lib/languageforge \
73-
&& mkdir -m 02775 -p /var/www/.local \
74-
&& chown www-data:www-data /var/www/.local
75-
76-
# rsyslog customizations (imklog reads kernel messages, which isn't allowed or desired in Docker containers)
77-
RUN sed -i '/load="imklog"/s/^/#/' /etc/rsyslog.conf
78-
79-
# php customizations
80-
COPY docker/app/customizations.php.ini $PHP_INI_DIR/conf.d/
81-
82-
# apache2 customizations
83-
RUN a2enmod headers rewrite
84-
COPY docker/app/000-default.conf /etc/apache2/sites-enabled
85-
8641
# COMPOSER-BUILDER
8742
# download composer app dependencies
8843
# git - needed for composer install
89-
FROM base-app AS composer-builder
44+
FROM sillsdev/web-languageforge:base-php AS composer-builder
9045
WORKDIR /composer
9146
COPY src/composer.json src/composer.lock /composer/
9247
ENV COMPOSER_ALLOW_SUPERUSER=1
9348
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* \
9449
&& install-php-extensions @composer && composer install
9550

9651
# PRODUCTION IMAGE
97-
FROM base-app AS production-app
52+
FROM sillsdev/web-languageforge:base-php AS production-app
9853
RUN rm /usr/local/bin/install-php-extensions
9954
RUN apt-get remove -y gnupg2
10055
RUN mv $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
10156

10257
# DEVELOPMENT IMAGE
103-
FROM base-app AS development-app
58+
FROM sillsdev/web-languageforge:base-php AS development-app
10459
RUN install-php-extensions xdebug
10560
COPY docker/app/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d
10661
RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini

docker/base-php/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM php:7.3.28-apache
2+
3+
# install apt packages
4+
# p7zip-full - used by LF application for unzipping lexicon uploads
5+
# unzip - used by LF application for unzipping lexicon uploads
6+
# gnupg2 - necessary for LFMerge package installation via SIL sources (will be uninstalled in production)
7+
# curl - used by LF application
8+
RUN apt-get update && apt-get -y install p7zip-full unzip gnupg2 curl && rm -rf /var/lib/apt/lists/*
9+
10+
# see https://github.com/mlocati/docker-php-extension-installer
11+
# PHP extensions required by the LF application
12+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
13+
RUN install-php-extensions gd mongodb intl
14+
15+
# install and configure LFMerge
16+
# LFMerge required apt packages
17+
# python - required by Mercurial (written in Python), which is bundled in the LFMerge apt package
18+
# lfmerge - main package, from SIL sources
19+
# rsyslog - lfmerge logs to rsyslog and expects this to exist
20+
# logrotate - TODO: is this required?
21+
# iputils-ping - Chorus (part of LFMerge) requires the "ping" command to be available on the command line
22+
RUN curl -L http://linux.lsdev.sil.org/downloads/sil-testing.gpg | apt-key add - \
23+
&& echo "deb http://linux.lsdev.sil.org/ubuntu bionic main" > /etc/apt/sources.list.d/linux-lsdev-sil-org.list \
24+
&& apt-get update \
25+
&& apt-get install --yes --no-install-recommends python lfmerge rsyslog logrotate iputils-ping \
26+
&& rm -rf /var/lib/apt/lists/*
27+
COPY docker/app/lfmerge.conf /etc/languageforge/conf/sendreceive.conf
28+
COPY docker/app/lfmergeqm-background.sh /
29+
RUN adduser www-data fieldworks \
30+
&& chown -R www-data:www-data /var/lib/languageforge \
31+
&& chmod 0755 /var/lib/languageforge \
32+
&& mkdir -m 02775 -p /var/www/.local \
33+
&& chown www-data:www-data /var/www/.local
34+
35+
# rsyslog customizations (imklog reads kernel messages, which isn't allowed or desired in Docker containers)
36+
RUN sed -i '/load="imklog"/s/^/#/' /etc/rsyslog.conf
37+
38+
# php customizations
39+
COPY docker/app/customizations.php.ini $PHP_INI_DIR/conf.d/
40+
41+
# apache2 customizations
42+
RUN a2enmod headers rewrite
43+
COPY docker/app/000-default.conf /etc/apache2/sites-enabled

0 commit comments

Comments
 (0)