Skip to content

Commit 6e673bc

Browse files
committed
Merge branch 'develop'
2 parents 2cac14b + 482dcbe commit 6e673bc

File tree

6 files changed

+132
-129
lines changed

6 files changed

+132
-129
lines changed

.circleci/config.yml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
version: 2
1+
version: 2.1
2+
23
jobs:
34
build:
4-
machine: true
55
working_directory: ~/logs
6-
6+
docker:
7+
- image: cimg/base:2022.09
8+
environment:
9+
DOCKER_VERSION: default
10+
BUILD_PATH: /tmp/container-build
11+
CONTAINER_NAME: apache
712
steps:
813
- checkout
14+
- setup_remote_docker
915
- run:
10-
name: Install Docker Compose
11-
command: |
12-
set -x
13-
sudo curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
14-
- run:
15-
name: Build Apache Docker image
16+
name: Build Apache Docker Image
1617
command: |
1718
cp .env.example .env
1819
make build
1920
20-
2121
# DEV Build
2222

2323
- run:
@@ -33,29 +33,28 @@ jobs:
3333
- run:
3434
name: Global Environment Vars
3535
command: |
36-
docker exec apache /bin/bash -c "export"
36+
docker exec ${CONTAINER_NAME} /bin/bash -c "export"
3737
3838
- run:
3939
name: DEV Build Tests
4040
command: |
41-
docker exec apache /bin/bash /opt/tests/build_tests.sh
41+
docker exec ${CONTAINER_NAME} /bin/bash /opt/tests/build_tests.sh
4242
4343
- run:
4444
name: Container Logs
4545
command: |
46-
mkdir -p /tmp/container-build
47-
docker logs apache > /tmp/container-build/log_output-DEV_Apache.txt
48-
docker logs apache_db > /tmp/container-build/log_output-DEV_MySQL.txt
46+
mkdir -p ${BUILD_PATH}
47+
docker logs ${CONTAINER_NAME} > ${BUILD_PATH}/log_output-DEV_Apache.txt
48+
docker logs db > ${BUILD_PATH}/log_output-DEV_MySQL.txt
4949
5050
- run:
51-
name: Kill running containers
51+
name: Kill running ${CONTAINER_NAME} containers
5252
command: |
5353
make stop
5454
55-
5655
# LIVE Build
5756

58-
- run:
57+
- run:
5958
name: Start LIVE Container
6059
command: |
6160
docker-compose --project-name apache up -d
@@ -65,21 +64,25 @@ jobs:
6564
- run:
6665
name: LIVE Build Tests
6766
command: |
68-
docker exec apache_hg-web_1 /bin/bash /opt/tests/build_tests.sh
67+
docker exec ${CONTAINER_NAME}-web-1 /bin/bash /opt/tests/build_tests.sh
6968
7069
- run:
7170
name: Container Logs
7271
command: |
73-
mkdir -p /tmp/container-build
74-
docker logs apache_hg-web_1 > /tmp/container-build/log_output-LIVE_Apache.txt
75-
docker logs apache_db_1 > /tmp/container-build/log_output-LIVE_MySQL.txt
72+
mkdir -p ${BUILD_PATH}
73+
docker logs ${CONTAINER_NAME}-web-1 > ${BUILD_PATH}/log_output-LIVE_Apache.txt
74+
docker logs ${CONTAINER_NAME}-db-1 > ${BUILD_PATH}/log_output-LIVE_MySQL.txt
7675
76+
- run:
77+
name: Kill running ${CONTAINER_NAME} containers
78+
command: |
79+
make stop
7780
81+
# Build Artifacts
7882

7983
- store_artifacts:
80-
path: /tmp/container-build
84+
path: ${BUILD_PATH}
8185
destination: raw-test-output
8286

8387
- store_test_results:
84-
path: /tmp/container-build
85-
88+
path: ${BUILD_PATH}

Dockerfile

Lines changed: 84 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1-
FROM ubuntu:18.04
2-
MAINTAINER Jason Gegere <jason@htmlgraphic.com>
1+
# Use a more recent base image
2+
FROM ubuntu:20.04
33

4-
ENV OS_LOCALE="en_US.UTF-8"
5-
RUN apt update && apt install -y locales && locale-gen ${OS_LOCALE}
6-
ENV LANG=${OS_LOCALE} \
4+
# Metadata as defined at http://label-schema.org
5+
LABEL org.label-schema.name="Apache Docker" \
6+
org.label-schema.description="Docker container running Apache on Ubuntu with Composer, Laravel, TDD via Shippable & CircleCI" \
7+
org.label-schema.url="https://htmlgraphic.com" \
8+
org.label-schema.vcs-url="https://github.com/htmlgraphic/Apache" \
9+
org.label-schema.vendor="HTMLgraphic, LLC" \
10+
org.label-schema.schema-version="1.0"
11+
12+
# Set non-interactive environment variables
13+
ENV DEBIAN_FRONTEND=noninteractive \
14+
TERM=xterm \
15+
OS_LOCALE="en_US.UTF-8" \
16+
LANG=${OS_LOCALE} \
717
LANGUAGE=${OS_LOCALE} \
8-
LC_ALL=${OS_LOCALE} \
9-
DEBIAN_FRONTEND=noninteractive
10-
11-
# Install packages then remove cache package list information
12-
RUN BUILD_DEPS='software-properties-common' \
13-
&& dpkg-reconfigure locales \
14-
&& apt install -y $BUILD_DEPS \
15-
&& add-apt-repository -y ppa:ondrej/php \
16-
&& add-apt-repository -y ppa:deadsnakes/ppa
17-
18-
RUN apt update && apt install -y python3.7 curl apache2 libsasl2-modules libapache2-mod-php7.4 libmcrypt-dev php7.4-cli php7.4-dev php7.4-readline php7.4-mbstring php7.4-zip php7.4-intl php7.4-xml php7.4-bcmath php7.4-xmlrpc php7.4-json php7.4-curl php7.4-gd php7.4-pgsql php7.4-mysql php-pear \
19-
&& apt update && apt install -yq --no-install-recommends \
18+
LC_ALL=${OS_LOCALE}
19+
20+
# Update and install locales
21+
RUN apt-get update && apt-get install -y locales && locale-gen ${OS_LOCALE}
22+
23+
# Install required packages
24+
RUN apt-get install -y \
25+
software-properties-common \
26+
python3.7 \
27+
curl \
28+
unzip \
29+
p7zip-full \
30+
apache2 \
31+
libsasl2-modules \
32+
libapache2-mod-php7.4 \
33+
libmcrypt-dev \
34+
php7.4-cli \
35+
php7.4-dev \
36+
php7.4-readline \
37+
php7.4-mbstring \
38+
php7.4-zip \
39+
php7.4-intl \
40+
php7.4-xml \
41+
php7.4-bcmath \
42+
php7.4-xmlrpc \
43+
php7.4-json \
44+
php7.4-curl \
45+
php7.4-gd \
46+
php7.4-pgsql \
47+
php7.4-mysql \
2048
git \
2149
cron \
2250
ghostscript \
@@ -33,89 +61,62 @@ RUN apt update && apt install -y python3.7 curl apache2 libsasl2-modules libapac
3361
vim \
3462
wget \
3563
postfix \
36-
&& apt purge -y --auto-remove $BUILD_DEPS \
37-
&& apt autoremove -y \
38-
&& rm -rf /var/lib/apt/lists/* \
39-
&& pecl channel-update pecl.php.net \
64+
&& apt-get autoremove -y \
65+
&& apt-get clean \
66+
&& rm -rf /var/lib/apt/lists/*
67+
68+
# Install additional packages from PPA
69+
RUN add-apt-repository -y ppa:ondrej/php \
70+
&& add-apt-repository -y ppa:deadsnakes/ppa \
71+
&& apt-get update && apt-get install -y
72+
73+
# Install and configure pecl extensions
74+
RUN pecl channel-update pecl.php.net \
4075
&& pecl install mcrypt-1.0.3 \
4176
&& pecl install redis -y
4277

43-
# POSTFIX
44-
RUN update-locale LANG=en_US.UTF-8
78+
# Enable Apache mods.
79+
RUN a2enmod userdir rewrite ssl
4580

46-
# Copy files to build app, add coming page to root apache dir, include self
47-
# signed SHA256 certs, unit tests to check over the setup
48-
RUN mkdir -p /opt
81+
# Copy files to build app, initial web configs, coming soon page ...
4982
COPY ./app /opt/app
5083
COPY ./tests /opt/tests
5184

52-
# Unit tests run via build_tests.sh
53-
RUN tar xf /opt/tests/shunit2-2.1.7.tar.gz -C /opt/tests/
54-
55-
# SUPERVISOR
85+
# Supervisor setup
5686
RUN chmod -R 755 /opt/* \
5787
&& mkdir -p /var/log/supervisor \
5888
&& cp /opt/app/supervisord /etc/supervisor/conf.d/supervisord.conf
5989

60-
# COMPOSER v2
61-
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
62-
RUN composer self-update --2
63-
RUN composer global require "laravel/installer"
64-
RUN composer global require "vlucas/phpdotenv"
65-
66-
# WP-CLI
67-
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp
90+
# Install Mod_pagespeed Module
91+
RUN curl -O https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb \
92+
&& dpkg -i mod-pagespeed-stable_current_amd64.deb \
93+
&& chown nobody:www-data /var/cache/mod_pagespeed \
94+
&& chown nobody:www-data /var/log/pagespeed/
6895

69-
# wkhtmltox > HTML > PDF Conversation
70-
RUN tar xf /opt/app/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -C /opt && mv /opt/wkhtmltox/bin/wk* /usr/bin/
71-
RUN wkhtmltopdf --version
96+
# Composer v2 installation
97+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
98+
RUN composer self-update --2 \
99+
&& composer global require "laravel/installer" \
100+
&& composer global require "vlucas/phpdotenv"
72101

73-
# Enable Apache mods.
74-
RUN a2enmod userdir rewrite ssl
102+
# Install WP-CLI
103+
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
104+
&& chmod +x wp-cli.phar \
105+
&& mv wp-cli.phar /usr/local/bin/wp
75106

76-
# Install Mod_pagespeed Module
77-
RUN curl -O https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb && dpkg -i mod-pagespeed-stable_current_amd64.deb
78-
RUN chown nobody:www-data /var/cache/mod_pagespeed && chown nobody:www-data /var/log/pagespeed/
79-
80-
81-
# Environment variables contained within build container.
82-
ENV TERM=xterm \
83-
LISTEN_PORT=80 \
84-
APACHE_RUN_USER=www-data \
85-
APACHE_RUN_GROUP=www-data \
86-
APACHE_LOG_DIR=/var/log/apache2 \
87-
APACHE_LOCK_DIR=/var/lock/apache2 \
88-
APACHE_PID_FILE=/var/run/apache2.pid \
89-
DOCKERCLOUD_SERVICE_FQDN=$DOCKERCLOUD_SERVICE_FQDN \
90-
LOG_TOKEN=$LOG_TOKEN \
91-
PATH="~/.composer/vendor/bin:$PATH"
92-
93-
# Build-time metadata as defined at http://label-schema.org
94-
ARG BUILD_DATE
95-
ARG VCS_REF
96-
ARG VERSION
97-
LABEL org.label-schema.build-date=$BUILD_DATE \
98-
org.label-schema.name="Apache Docker" \
99-
org.label-schema.description="Docker container running Apache running on Ubuntu, Composer, Lavavel, TDD via Shippable & CircleCI" \
100-
org.label-schema.url="https://htmlgraphic.com" \
101-
org.label-schema.vcs-ref=$VCS_REF \
102-
org.label-schema.vcs-url="https://github.com/htmlgraphic/Apache" \
103-
org.label-schema.vendor="HTMLgraphic, LLC" \
104-
org.label-schema.version=$VERSION \
105-
org.label-schema.schema-version="1.0"
107+
# Install wkhtmltox for HTML to PDF conversion
108+
RUN tar xf /opt/app/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -C /opt \
109+
&& mv /opt/wkhtmltox/bin/wk* /usr/bin/ \
110+
&& wkhtmltopdf --version
106111

107-
# Add VOLUMEs for persistant data or to allow various
108-
# backups of config and databases via --volumes-from
109-
# http://bit.ly/autobuild-and-autodeploy
110-
VOLUME ["/backup"]
111-
VOLUME ["/data"]
112-
VOLUME ["/etc/letsencrypt"]
112+
# Unit tests run via build_tests.sh
113+
RUN tar xf /opt/tests/shunit2-2.1.7.tar.gz -C /opt/tests/
113114

115+
# Volumes for persistent data
116+
VOLUME ["/backup", "/data", "/etc/letsencrypt"]
114117

115-
# Note that EXPOSE only works for inter-container links. It doesn't make ports
116-
# accessible from the host. To expose port(s) to the host, at runtime, use the -p flag.
118+
# Expose ports
117119
EXPOSE 80 443
118120

119-
120-
#CMD ["/opt/app/run.sh", "env | grep _ >> /etc/environment && supervisord -n"]
121+
# Entrypoint command
121122
CMD ["/opt/app/run.sh"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ run:
6262
@echo "Checking... initial directory structure \n"
6363
@if [ $(NODE_ENV) == 'dev' ]; then \
6464
if [ ! -d "~/SITES/docker" ]; then \
65-
echo " Creating project folders \n" && sudo mkdir -p ~/SITES && sudo mkdir -p ~/SITES/docker; fi \
65+
echo " Creating project folders \n" && sudo mkdir -p ~/SITES/docker && sudo chmod 777 ~/SITES/docker ; fi \
6666
fi
6767
@echo "${bold}Run the following on the MySQL container, to setup a GLOBAL admin:${normal}\n"
6868
@echo " THE PASSWORD FOR ${bold}$(MYSQL_USER)${normal} IS ${bold}$(MYSQL_PASSWORD)${normal};"

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Circle CI](https://circleci.com/gh/htmlgraphic/Apache/tree/master.svg?style=svg)](https://circleci.com/gh/htmlgraphic/Apache/tree/master)
55
[![](https://images.microbadger.com/badges/image/htmlgraphic/apache:latest.svg)](https://microbadger.com/images/htmlgraphic/apache:latest "Get your own image badge on microbadger.com")
66

7-
This repo will give you a turn key Docker container build for use in **production** OR **dev**. The setup includes an Apache/2.4.29 web service, PHP Version 7.4+, PHP Composer, linked [MySQL 5.7.29](https://hub.docker.com/_/mysql) instance and a data container volume.
7+
This repo will give you a turn key Docker container build for use in **production** OR **dev**. The setup includes Apache/2.4.29 build, PHP 7.4+, PHP Composer, [MySQL 8.3.0](https://hub.docker.com/_/mysql) instance and a data container volume.
88

99
Using containers offer a huge advantage when developing locally or in prodcution. Use this containers for development and deployment. Changing `NODE_ENVIRONMENT` within to `.env` to `dev` or `production` will offer a dynamic environment.
1010

@@ -54,30 +54,32 @@ The **Apache** container the directory `/data` is shared to your local system vi
5454

5555
Docker Compose File Reference [more info](https://docs.docker.com/compose/compose-file/)
5656

57+
Open `docker-compose.local.yml` and review [this line](https://github.com/htmlgraphic/Apache/blob/master/docker-compose.local.yml#L8). This path will link files from your local dev env to the Docker Instance with the `/data` directory. Upon the intial `make run` execution, the same path needs to be listed for proper permissions within the Docker Instance to write files to the linked OS.
58+
5759

5860
### Mac OS X / Linux
5961

6062
> Type `make` for more build options:
6163
6264
```bash
63-
> git clone https://github.com/htmlgraphic/Apache.git ~/Docker/Apache && cd ~/Docker/Apache
64-
> cp .env.example .env
65-
> make run
65+
~ git clone https://github.com/htmlgraphic/Apache.git ~/Docker/Apache && cd ~/Docker/Apache
66+
~ cp .env.example .env
67+
~ make run
6668
```
6769

6870
### Windows
6971

7072
```bash
71-
> git clone https://github.com/htmlgraphic/Apache.git ~/Docker/Apache; cd ~/Docker/Apache
72-
> copy .env.example .env
73-
> docker-compose -f docker-compose.local.yml up -d
73+
~ git clone https://github.com/htmlgraphic/Apache.git ~/Docker/Apache; cd ~/Docker/Apache
74+
~ copy .env.example .env
75+
~ docker-compose -f docker-compose.local.yml up -d
7476
```
7577

7678
> Optional, are you having problems on Windows? Disable Firewall
7779
7880
```bash
79-
> netsh advfirewall show currentprofile
80-
> netsh advfirewall set allprofiles state off
81+
~ netsh advfirewall show currentprofile
82+
~ netsh advfirewall set allprofiles state off
8183
```
8284

8385

docker-compose.local.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
version: '3.3'
1+
version: '3.9'
22
services:
33
web:
44
image: 'htmlgraphic/apache:latest'
55
restart: unless-stopped
66
container_name: apache
77
volumes:
8-
- '~/SITES/docker:/data' # <- Change to preferred local working dir
8+
- '~/SITES/docker:/data' # Preferred local working dir
99
#- '/c/Users/southpark/docker:/data'
1010
links:
1111
- 'db:mysql'
@@ -14,16 +14,15 @@ services:
1414
- '443:443'
1515
env_file:
1616
- .env
17-
# extra_hosts:
18-
# - "mysql:10.13.32.113"
1917
logging:
2018
driver: "json-file"
2119
options:
2220
max-size: "200k"
2321
max-file: "10"
2422
db:
25-
image: 'mysql:5.7.29'
26-
container_name: apache_db
23+
image: 'mysql:8.3.0'
24+
restart: unless-stopped
25+
container_name: db
2726
volumes:
2827
- 'db-data:/var/lib/mysql'
2928
ports:

0 commit comments

Comments
 (0)