Skip to content

Commit

Permalink
PR #27 fix:🐛 Apache/PHP Environment variables access
Browse files Browse the repository at this point in the history
  • Loading branch information
alchatti authored Jan 11, 2024
2 parents e4a0839 + 95b9dd5 commit 9dad8b9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ARG VARIANT

FROM mcr.microsoft.com/vscode/devcontainers/php:${VARIANT}-bookworm
FROM mcr.microsoft.com/vscode/devcontainers/php:${VARIANT}-apache-bookworm

ARG VARIANT
ARG CREATE_DATE
Expand All @@ -25,16 +25,20 @@ LABEL org.opencontainers.image.created=$CREATE_DATE
ENV APACHE_SERVER_NAME="localhost"
ENV APACHE_DOCUMENT_ROOT "docroot"
ENV WORKSPACE_ROOT "/var/www/html"
ENV DCR "/var/www/html/docroot"
ENV WR "/var/www/html"
# Default theme
# ENV Default theme for Oh My Posh
ENV POSH_THEME_ENVIRONMENT "ys"
# Shortcut to make development easier
ENV W $WORKSPACE_ROOT
ENV D $WORKSPACE_ROOT/$APACHE_DOCUMENT_ROOT


RUN echo "${CREATE_DATE}" >> /var/.buildInfo

# Apache Configurations
RUN sed -ri -e 's!/var/www/html!${WORKSPACE_ROOT}/${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN echo "ServerName ${APACHE_SERVER_NAME}" >> /etc/apache2/apache2.conf
RUN echo "PassEnv APACHE_DOCUMENT_ROOT" >> /etc/apache2/apache2.conf
RUN echo "PassEnv WORKSPACE_ROOT" >> /etc/apache2/apache2.conf

# Drupal filesystem
RUN mkdir /mnt/files && \
Expand Down Expand Up @@ -201,3 +205,5 @@ RUN set -eux; \
rm -rf /var/lib/apt/lists/* \
rm -r /tmp/*\
;

USER vscode
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ The following are environment variables for customization.

```bash
# ENV Defaults fpr APACHE
ENV APACHE_SERVER_NAME="localhost"
ENV APACHE_SERVER_NAME "localhost"
ENV APACHE_DOCUMENT_ROOT "docroot"
ENV WORKSPACE_ROOT "/var/www/html"
ENV WR # Alias for WORKSPACE_ROOT
# Default theme
# ENV Default theme for Oh My Posh
ENV POSH_THEME_ENVIRONMENT "ys"
```

Expand Down Expand Up @@ -194,6 +193,7 @@ The workflow is set on schedule and triggered on push to the main branch. It als
- docker/setup-buildx-action@v`2.0.0`->`3`
- docker/build-push-action@v`3`->`5`
- ci: switch to `peter-evans/dockerhub-description@v3` as it is being maintained.
- fix: PassEnv `APACHE_DOCUMENT_ROOT` & `WORKSPACE_ROOT` in apache2.conf to enable in `/etc/apache2/sites-available/*.conf`

### December 2023

Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ do
--build-arg NODE_VERSION="$NODE" \
--build-arg CREATE_DATE="$timestamp" \
--build-arg TARGETARCH=$TARGETARCH \
--no-cache \
-t local/drupal-devcontainer:"$tag"-$NODE \
-t local/drupal-devcontainer:latest .

Expand Down
8 changes: 6 additions & 2 deletions scripts/startup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/bash

printf "👋 Welcome to the world of Dev Containers...\n\n"
apache2ctl start

printf "\n⚒️ Image Details "
about.sh d | jq

printf "\n⚙️ Apache kick starting..\n"
apachectl stop
apachectl start
printf "Apache Ready! 🚀\n"

printf "\n💡 Hints"
echo '{"$WR":"/var/www/html", "$DCR": "/var/www/html/docroot"}' | jq
echo '{"$W":"'$WORKSPACE_ROO./T'", "$D": "'$WORKSPACE_ROOT/$APACHE_DOCUMENT_ROOT'"}' | jq

printf "\n"
2 changes: 2 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ docker run --rm -it \
-u "vscode" \
-p 80:80 \
-v "drupal-dev-html:/var/www/html" \
-e "TESTING_1=⭐⭐⭐Hello World!⭐⭐⭐" \
-e "TESTING_2=🚀🛸🛰️🕳️💫" \
local/drupal-devcontainer:latest fish

0 comments on commit 9dad8b9

Please sign in to comment.