Skip to content

Commit

Permalink
Fixes: DocumentRoot File permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
b23prodtm committed Jul 9, 2020
1 parent 38e8c14 commit 0206af7
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ install:
- ./deploy.sh "$(arch)" --nobuild --exit

before_script:
- mkdir -p ${MYPHPCMS_LOG}
script:
- if [[ "${TRAVIS_OS_NAME}" != "linux" && "${COVERITY_SCAN_BRANCH:-0}" != 1 ]]; then ./test-cake.sh --travis --phpcs || true; fi
- if [[ "${TRAVIS_OS_NAME}" = "linux" && "${COVERITY_SCAN_BRANCH:-0}" != 1 ]]; then ./test-cake.sh --travis; fi
Expand All @@ -104,7 +105,7 @@ after_success:
- chmod +x send.sh
- "./send.sh success $WEBHOOK_URL"
- zip -r acake2php.zip * > /dev/null
- git tag --force "v${GIT_RELEASE_VERSION}.${TRAVIS_BUILD_NUMBER}"
- git tag --force "${GIT_RELEASE_VERSION}.${TRAVIS_BUILD_NUMBER}"
deploy:
provider: releases
api_key:
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ARG PGID
ENV PGID ${PGID:-0}
# Must own the ip address
ARG HTTPD_LISTEN
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'0.0.0.0:80'}
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'*:80'}

# Use the default production configuration
#COPY $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
Expand Down Expand Up @@ -89,24 +89,24 @@ RUN ./vagrant-shell.sh php-settings-update extension memcached.so \
&& ./vagrant-shell.sh php-settings-update session.save_handler memcached \
&& ./vagrant-shell.sh php-settings-update session.save_path '127.0.0.1:11211,127.0.0.1:11212'

# Copy the source code into /var/www/html/ inside the image
COPY . /var/www/html/
# Copy the source code into /var/www/localhost/htdocs/ inside the image
COPY . /var/www/localhost/htdocs/

# Configure the application
WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

# Change mode of bash Scripts
RUN chmod -R gu+xs deploy.sh configure.sh migrate-database.sh Scripts/

# Add cake and composer command to system path
ENV PATH "${PATH}:/var/www/html/app/Console"
ENV PATH "${PATH}:/var/www/html/app/Vendor/bin"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Console"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Vendor/bin"

# Enable site on httpd
RUN Scripts/config_a2ensite.sh /var/www/html/app/webroot
RUN Scripts/config_a2ensite.sh /var/www/localhost/htdocs/app/webroot

# Add to hosts
RUN echo "127.0.0.1 ${SERVER_NAME}" | tee -a /etc/hosts
RUN echo "127.0.0.1 ${SERVER_NAME} www.${SERVER_NAME}" >> /etc/hosts

# Password Hash Verbose
# RUN cat app/webroot/php_cms/e13/etc/export_hash_password.sh | awk -F= '{print $2}' | tail -n 1
Expand All @@ -125,7 +125,7 @@ RUN mkdir -p \
# Helper packages
RUN npm link balena-cloud

WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

RUN chmod 0755 *.sh
RUN ./deploy.sh ${DKR_ARCH} --nobuild --exit \
Expand Down
20 changes: 10 additions & 10 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ARG CAKEPHP_DEBUG_LEVEL
ENV CAKEPHP_DEBUG_LEVEL ${CAKEPHP_DEBUG_LEVEL:-2}
ENV BALENA_MACHINE_NAME ${BALENA_MACHINE_NAME:-%%BALENA_MACHINE_NAME%%}
ARG SECONDARY_HUB
ENV SECONDARY_HUB ${SECONDARY_HUB:-'linuxserver\\/mariadb'}
ENV SECONDARY_HUB ${SECONDARY_HUB:-'linuxserver/mariadb'}
ENV DKR_ARCH ${DKR_ARCH:-%%BALENA_ARCH%%}
ARG COLLECT_COVERAGE
ENV COLLECT_COVERAGE ${COLLECT_COVERAGE:-'False'}
Expand Down Expand Up @@ -58,7 +58,7 @@ ARG PGID
ENV PGID ${PGID:-0}
# Must own the ip address
ARG HTTPD_LISTEN
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'0.0.0.0:80'}
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'*:80'}

# Use the default production configuration
#COPY $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
Expand Down Expand Up @@ -89,24 +89,24 @@ RUN ./vagrant-shell.sh php-settings-update extension memcached.so \
&& ./vagrant-shell.sh php-settings-update session.save_handler memcached \
&& ./vagrant-shell.sh php-settings-update session.save_path '127.0.0.1:11211,127.0.0.1:11212'

# Copy the source code into /var/www/html/ inside the image
COPY . /var/www/html/
# Copy the source code into /var/www/localhost/htdocs/ inside the image
COPY . /var/www/localhost/htdocs/

# Configure the application
WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

# Change mode of bash Scripts
RUN chmod -R gu+xs deploy.sh configure.sh migrate-database.sh Scripts/

# Add cake and composer command to system path
ENV PATH "${PATH}:/var/www/html/app/Console"
ENV PATH "${PATH}:/var/www/html/app/Vendor/bin"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Console"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Vendor/bin"

# Enable site on httpd
RUN Scripts/config_a2ensite.sh /var/www/html/app/webroot
RUN Scripts/config_a2ensite.sh /var/www/localhost/htdocs/app/webroot

# Add to hosts
RUN echo "127.0.0.1 ${SERVER_NAME}" | tee -a /etc/hosts
RUN echo "127.0.0.1 ${SERVER_NAME} www.${SERVER_NAME}" >> /etc/hosts

# Password Hash Verbose
# RUN cat app/webroot/php_cms/e13/etc/export_hash_password.sh | awk -F= '{print $2}' | tail -n 1
Expand All @@ -125,7 +125,7 @@ RUN mkdir -p \
# Helper packages
RUN npm link balena-cloud

WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

RUN chmod 0755 *.sh
RUN ./deploy.sh ${DKR_ARCH} --nobuild --exit \
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ARG PGID
ENV PGID ${PGID:-0}
# Must own the ip address
ARG HTTPD_LISTEN
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'0.0.0.0:80'}
ENV HTTPD_LISTEN ${HTTPD_LISTEN:-'*:80'}

# Use the default production configuration
#COPY $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
Expand Down Expand Up @@ -89,24 +89,24 @@ RUN ./vagrant-shell.sh php-settings-update extension memcached.so \
&& ./vagrant-shell.sh php-settings-update session.save_handler memcached \
&& ./vagrant-shell.sh php-settings-update session.save_path '127.0.0.1:11211,127.0.0.1:11212'

# Copy the source code into /var/www/html/ inside the image
COPY . /var/www/html/
# Copy the source code into /var/www/localhost/htdocs/ inside the image
COPY . /var/www/localhost/htdocs/

# Configure the application
WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

# Change mode of bash Scripts
RUN chmod -R gu+xs deploy.sh configure.sh migrate-database.sh Scripts/

# Add cake and composer command to system path
ENV PATH "${PATH}:/var/www/html/app/Console"
ENV PATH "${PATH}:/var/www/html/app/Vendor/bin"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Console"
ENV PATH "${PATH}:/var/www/localhost/htdocs/app/Vendor/bin"

# Enable site on httpd
RUN Scripts/config_a2ensite.sh /var/www/html/app/webroot
RUN Scripts/config_a2ensite.sh /var/www/localhost/htdocs/app/webroot

# Add to hosts
RUN echo "127.0.0.1 ${SERVER_NAME}" | tee -a /etc/hosts
RUN echo "127.0.0.1 ${SERVER_NAME} www.${SERVER_NAME}" >> /etc/hosts

# Password Hash Verbose
# RUN cat app/webroot/php_cms/e13/etc/export_hash_password.sh | awk -F= '{print $2}' | tail -n 1
Expand All @@ -125,7 +125,7 @@ RUN mkdir -p \
# Helper packages
RUN npm link balena-cloud

WORKDIR /var/www/html/
WORKDIR /var/www/localhost/htdocs/

RUN chmod 0755 *.sh
RUN ./deploy.sh ${DKR_ARCH} --nobuild --exit \
Expand Down
6 changes: 4 additions & 2 deletions Scripts/config_a2ensite.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -eu
CNF="/etc/apache2"
# DO
WWW="${1:-/var/www/localhost/htdocs}"
mkdir -p "$(dirname "$CNF")"
mkdir -p "$(dirname "$WWW")"
touch site.conf
echo -e "
<Directory \"/\">
AllowOverride All
Require all denied
</Directory>
<VirtualHost ${HTTPD_LISTEN}>
Expand All @@ -20,8 +22,8 @@ echo -e "
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.${SERVER_NAME}.log
CustomLog /var/log/apache2/access.${SERVER_NAME}.log combined
ErrorLog log/error.${SERVER_NAME}.log
CustomLog log/access.${SERVER_NAME}.log combined
</VirtualHost>
ServerName ${SERVER_NAME}
" >> site.conf
Expand Down
2 changes: 1 addition & 1 deletion common.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PGID=1000
PUID=1000
HTTPD_LISTEN=0.0.0.0:80
HTTPD_LISTEN=*:80
BALENA_PROJECTS_FLAGS=(IMG_TAG PRIMARY_HUB SECONDARY_HUB)
COLLECT_COVERAGE=false
DATABASE_USER=root
Expand Down
4 changes: 2 additions & 2 deletions deployment/images/apache-php7/etc/apache2/conf.d/site.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
DocumentRoot /var/www/localhost/htdocs
<Directory /var/www/localhost/htdocs>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
volumes:
- db-data:/config
- db-socket:/var/run/mysqld
- data:/var/www/html
- data:/var/www/
ports:
- "3306:3306"
restart: unless-stopped
Expand All @@ -40,12 +40,11 @@ services:
MYSQL_HOST: "db"
PUID: 1000
PGID: 1000
HTTPD_LISTEN: "0.0.0.0:80"
image: betothreeprod/acake2php-raspberrypi3
labels:
io.balena.features.dbus: "1"
volumes:
- data:/var/www/html
- data:/var/www
- db-socket:/var/run/mysqld
ports:
#Dockerfile's exposed 80 (through apache2), forward 8000 as of CakePHP default port setting
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
volumes:
- db-data:/config
- db-socket:/var/run/mysqld
- data:/var/www/html
- data:/var/www
ports:
- "3306:3306"
restart: unless-stopped
Expand All @@ -40,12 +40,11 @@ services:
MYSQL_HOST: "db"
PUID: 1000
PGID: 1000
HTTPD_LISTEN: "127.0.0.1:80"
image: betothreeprod/acake2php-intel-nuc
labels:
io.balena.features.dbus: "1"
volumes:
- data:/var/www/html
- data:/var/www
- db-socket:/var/run/mysqld
ports:
#Dockerfile's exposed 80 (through apache2), forward 8000 as of CakePHP default port setting
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
volumes:
- db-data:/config
- db-socket:/var/run/mysqld
- data:/var/www/html
- data:/var/www
ports:
- "3306:3306"
restart: unless-stopped
Expand All @@ -40,12 +40,11 @@ services:
MYSQL_HOST: "db"
PUID: 1000
PGID: 1000
HTTPD_LISTEN: "0.0.0.0:80"
image: betothreeprod/acake2php-%%BALENA_MACHINE_NAME%%
labels:
io.balena.features.dbus: "1"
volumes:
- data:/var/www/html
- data:/var/www
- db-socket:/var/run/mysqld
ports:
#Dockerfile's exposed 80 (through apache2), forward 8000 as of CakePHP default port setting
Expand Down
4 changes: 3 additions & 1 deletion etc/services.d/apache/setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if grep www-data < /etc/passwd; then
else
adduser --ingroup www-data --system www-data
fi

chown -R www-data:www-data /var/www \
&& chmod -R g+s /var/www
mkdir -p /var/www/log
memcached -d -l 127.0.0.1 -p 11211 -u www-data -m 16 \
&& memcached -d -l 127.0.0.1 -p 11212 -u www-data -m 16

0 comments on commit 0206af7

Please sign in to comment.