Skip to content

Commit c694236

Browse files
authored
Merge pull request #17 from LibreCodeCoop/fix/issue-8-npm-runtime
fix: make npm available in php runtime and align entrypoint shell
2 parents a1cbe1d + 2fe334e commit c694236

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

.docker/php/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \
3737

3838
COPY --from=composer /usr/bin/composer /usr/bin/composer
3939

40-
# Install NVM
41-
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
42-
&& export NVM_DIR="/root/.nvm" \
43-
&& . "$NVM_DIR/nvm.sh" \
44-
&& nvm install 20 \
45-
&& nvm alias default 20
40+
# Install Node.js and npm from official Node image
41+
COPY --from=node:20-bookworm-slim /usr/local/lib/node_modules /usr/local/lib/node_modules
42+
COPY --from=node:20-bookworm-slim /usr/local/bin/node /usr/local/bin/node
43+
RUN ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
44+
&& ln -sf /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
4645

4746
COPY config/php.ini /usr/local/etc/php/conf.d/
4847

4948
WORKDIR /var/www/html
5049
COPY wait-for-db.php /usr/local/bin/wait-for-db.php
5150
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
52-
ENTRYPOINT ["sh", "/usr/local/bin/entrypoint.sh"]
51+
ENTRYPOINT ["bash", "/usr/local/bin/entrypoint.sh"]

.docker/php/entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ ! -f "vendor/autoload.php" ]; then
99
git clone --progress -b "${AKAUNTING_VERSION}" --single-branch --depth 1 https://github.com/akaunting/akaunting /tmp/akaunting
1010
rsync -r /tmp/akaunting/ .
1111
rm -rf /tmp/akaunting
12-
if [ $APP_ENV == "production" ]; then
12+
if [ "${APP_ENV}" = "production" ]; then
1313
composer install --no-dev --no-scripts
1414
else
1515
composer install --no-scripts
@@ -19,11 +19,11 @@ if [ ! -f "vendor/autoload.php" ]; then
1919
composer dump-autoload
2020
php artisan install --no-interaction --db-host="${DB_HOST}" --db-port="${DB_PORT}" --db-name="${DB_DATABASE}" --db-username="${DB_USERNAME}" --db-password="${DB_PASSWORD}" --db-prefix="${DB_PREFIX}" --admin-email="${ADM_EMAIL}" --admin-password="${ADM_PASSWD}"
2121
npm ci
22-
if [ $APP_ENV == "production" ]; then
22+
if [ "${APP_ENV}" = "production" ]; then
2323
npm run production
2424
else
2525
npm run dev
2626
fi
2727
chown -R www-data:www-data .
2828
fi
29-
php-fpm
29+
exec php-fpm

0 commit comments

Comments
 (0)