Skip to content

Commit

Permalink
fix: Do not use SSH keys volumes to share credentials between host an…
Browse files Browse the repository at this point in the history
…d container, use `COMPOSER_DEPLOY_TOKEN`
  • Loading branch information
ambroisemaupate committed Nov 26, 2024
1 parent 16ff3f0 commit 4d01411
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=8.3.13
ARG PHP_VERSION=8.3.14
ARG MYSQL_VERSION=8.0.40
ARG SOLR_VERSION=9
ARG VARNISH_VERSION=7.1
Expand Down Expand Up @@ -56,7 +56,6 @@ curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/l
chmod +x /usr/local/bin/install-php-extensions
install-php-extensions \
@composer-${COMPOSER_VERSION} \
amqp \
bcmath \
exif \
fileinfo \
Expand All @@ -71,7 +70,6 @@ install-php-extensions \
pcntl \
pdo_mysql \
simplexml \
soap \
xsl \
zip \
redis-${PHP_EXTENSION_REDIS_VERSION}
Expand All @@ -85,6 +83,11 @@ WORKDIR /var/www/html

FROM php AS php-dev

# If you depend on private Gitlab repositories, you must use a deploy token and username
# to use composer commands inside you
#ARG COMPOSER_DEPLOY_TOKEN
#ARG COMPOSER_DEPLOY_TOKEN_USER="gitlab+deploy-token-1"

ENV APP_ENV=dev
ENV APP_RUNTIME_ENV=dev
ENV APP_DEBUG=1
Expand All @@ -101,12 +104,17 @@ apt-get --quiet --yes --purge --autoremove upgrade
# Packages - System
apt-get --quiet --yes --no-install-recommends --verbose-versions install make
rm -rf /var/lib/apt/lists/*
# Prepare folder to install composer credentials
install --owner=www-data --group=www-data --mode=755 --directory /var/www/.composer
EOF

VOLUME /var/www/html

USER www-data

# If you depend on private Gitlab repositories, you must use a deploy token and username
#RUN composer config --global gitlab-token.gitlab.rezo-zero.com ${COMPOSER_DEPLOY_TOKEN_USER} ${COMPOSER_DEPLOY_TOKEN}


##################
# PHP Production #
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Edit your `.env.local` and `docker-compose.yml` files according to your local en
```shell
# Copy override file to customize your local environment
cp compose.override.yml.dist compose.override.yml

# Do not forget to add your COMPOSER_DEPLOY_TOKEN and COMPOSER_DEPLOY_TOKEN_USER
# in compose.override.yml to configure your container to fetch private repositories.
docker compose build
docker compose up -d --force-recreate
```
Expand All @@ -49,7 +50,7 @@ your app container to install your dependencies.

```shell
# This command will run once APP container to install your dependencies without starting other services
docker compose run --rm --no-deps --entrypoint= app composer install
docker compose run --rm --no-deps --entrypoint= app composer install -o
```

To access your app services, you will have to expose ports locally in your `compose.override.yml` file.
Expand Down Expand Up @@ -77,11 +78,13 @@ services:
pma:
ports:
- ${PUBLIC_PMA_PORT}:80/tcp
# If you depend on private Gitlab repositories, you must use a deploy token and username
#app:
# # If your project requires private package you can share your ssh keys with the container
# volumes:
# - ./:/var/www/html:cached
# - /home/my-user/.ssh/id_ed25519:/home/www-data/.ssh/id_ed25519:ro
# build:
# args:
# USER_UID: ${USER_UID}
# COMPOSER_DEPLOY_TOKEN: xxxxxxxxxxxxx
# COMPOSER_DEPLOY_TOKEN_USER: "gitlab+deploy-token-1"

#solr:
# ports:
Expand Down
11 changes: 7 additions & 4 deletions compose.override.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ services:
pma:
ports:
- ${PUBLIC_PMA_PORT}:80/tcp

# If you depend on private Gitlab repositories, you must use a deploy token and username
#app:
# # If your project requires private package you can share your ssh keys with the container
# volumes:
# - ./:/var/www/html
# - /home/my-user/.ssh/id_ed25519:/home/www-data/.ssh/id_ed25519:ro
# build:
# args:
# USER_UID: ${USER_UID}
# COMPOSER_DEPLOY_TOKEN: xxxxxxxxxxxxx
# COMPOSER_DEPLOY_TOKEN_USER: "gitlab+deploy-token-1"

#solr:
# ports:
Expand Down

0 comments on commit 4d01411

Please sign in to comment.