Skip to content

Commit

Permalink
update docker script
Browse files Browse the repository at this point in the history
  • Loading branch information
surgiie committed Mar 10, 2024
1 parent 8d9403e commit bf7754e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ Then you can render a file like so:

```bash
# mount the file to the container
docker cp template laravel-blade-cli-0.1.0:/app/template
docker cp template laravel-blade-cli:/app/template
laravel-blade render /app/template --var="example"
# copy the rendered file back to your host
docker cp laravel-blade-cli-0.1.0:/app/template.rendered ./template.rendered
docker cp laravel-blade-cli:/app/template.rendered ./template.rendered
```

Consider creating a bash function to ease the process of mounting and copying files to and from the container.
Expand Down
19 changes: 3 additions & 16 deletions docker
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

# The version of laravel-blade to use.
cli_version="0.1.0"
# The container name to use.
container_name="laravel-blade-cli-$cli_version"
container_name="laravel-blade-cli"

# Is TTY supported?
test -t 1 && USE_TTY="-t"
Expand All @@ -14,15 +12,6 @@ mkdir -p $workspace

cd $workspace

# Write temporary build/dependency files to do the build.
cat > composer.json <<EOF
{
"require": {
"surgiie/laravel-blade-cli": "^$cli_version"
}
}
EOF

cat > Dockerfile <<EOF
FROM php:8.3-cli-alpine
Expand All @@ -32,22 +21,20 @@ WORKDIR /app
ARG PHP_EXTS="pcntl"
ARG DEBIAN_FRONTEND=noninteractive
COPY --chown=php:php composer.json composer.json
RUN apk --no-cache update \\
&& docker-php-ext-install -j\$(nproc) \${PHP_EXTS} \\
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \\
&& chown -R php:php /app/
USER php
RUN composer install
RUN composer require surgiie/laravel-blade-cli
ENV PATH=\$PATH:/app/vendor/bin
EOF
# Create a sha1sum of the Dockerfile to use to suffix the image tag so if any changes to dockerfile are made, a new image is built.
sha1sum=$(sha1sum Dockerfile | awk '{print $1}')
image_tag="laravel-blade-cli:$cli_version-$sha1sum"
image_tag="laravel-blade-cli:$sha1sum"

# Build docker image for the cli if not already present or allow with a flag to force build.
if [ -z "$(docker images -q $image_tag)" ] || [[ " $@ " =~ "--docker-build" ]]
Expand Down

0 comments on commit bf7754e

Please sign in to comment.