Skip to content

Commit

Permalink
ci: 👷 changed to building imagick from source (#2428)
Browse files Browse the repository at this point in the history
* ci: 👷 changed to building imagick from source

* docs: 📝 updated docker comments

* docs: 📝 added reference to issue in comments

* docs: added TODOs for the removal of items

* docs: 📝 updated issue referenced in todo comments

* fix: imagick version as variable not working in curl command

* docs: 📝 removed instructions for straight docker compose

---------

Co-authored-by: Justin Obara <[email protected]>
  • Loading branch information
marvinroman and jobara authored Jan 29, 2025
1 parent 8f3c39e commit c7a8fb7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 146 deletions.
30 changes: 28 additions & 2 deletions .kube/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,30 @@ RUN apt-get install -y \
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install -j$(nproc) gd pdo_mysql mbstring exif pcntl bcmath bz2 zip soap intl opcache

RUN apt-get install -y libmagickwand-dev --no-install-recommends
RUN apt-get install -y \
libmagickwand-dev \
libmagickcore-dev \
--no-install-recommends

RUN pecl install imagick
# START BUILDING IMAGICK FROM SOURCE - this can be removed once pecl fixes issues installing with php8.4
# TODO - this can be removed when https://github.com/Imagick/imagick/issues/698 is resolved
RUN apt-get install -y \
$PHPIZE_DEPS \
libtool

RUN mkdir -p /tmp/imagick
WORKDIR /tmp/imagick
RUN curl -L -o /tmp/imagick.tar.gz https://github.com/Imagick/imagick/archive/refs/tags/3.7.0.tar.gz # upgrade version when bumping PHP version
RUN tar --strip-components=1 -xf /tmp/imagick.tar.gz
RUN phpize
RUN ./configure
RUN make
RUN make install
WORKDIR /
RUN rm -rf /tmp/imagick
# END BUILDING IMAGICK FROM SOURCE

# RUN pecl install imagick
RUN docker-php-ext-enable imagick

RUN printf "\n" | pecl install apcu
Expand All @@ -48,6 +69,11 @@ RUN pecl install -o -f redis && \
rm -rf /tmp/pear && \
docker-php-ext-enable redis

# TODO - this can be removed when https://github.com/Imagick/imagick/issues/698 is resolved
RUN apt-get remove -y \
$PHPIZE_DEPS \
libtool

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN mkdir -p $NVM_DIR
Expand Down
155 changes: 11 additions & 144 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,151 +179,17 @@ of how some key tasks can be carried out using Herd:
Herd supports debuging via XDebug. The article "[Activating XDebug on Visual Studio Code & Laravel Herd](https://thomashysselinckx.medium.com/activating-xdebug-on-visual-studio-code-laravel-herd-cfd0553d26e0)" can help if you are having trouble getting it setup with VS Code.
### Local development setup using docker compose:
1. Install docker according to your platform instructions found [here](https://docs.docker.com/get-docker/).
2. Clone the repository:
### Local development using Docker and Nix
```bash
git clone https://github.com/accessibility-exchange/platform.git && cd platform
```
3. Create a `.env` file from the included example file:
```bash
cp .env.local.example .env
```
Then, change the `APP_ENV` value to `local`:
```dotenv
APP_ENV=local
```
4. Generate an encryption key for [CipherSweet](https://github.com/spatie/laravel-ciphersweet):
```bash
docker run --rm -it alpine apk add openssl && openssl rand -hex 32
```
Add it to your `.env` file:
```dotenv
CIPHERSWEET_KEY="<your key>"
```
5. Generate your database password:
1. Install [Nix](https://nixos.org/download/) for your system.
2. Run `nix-shell`.
3. If you are wanting to run dockers then follow the steps for your platform.
1. **Linux** On linux there are added aliases `dstart` & `dstop` that will start and stop the docker daemon which will run using rootlesskit.
* When using rootless you will want to make sure that Rootless is setup and allowed to run on priveleged ports. https://github.com/rootless-containers/rootlesskit/blob/master/docs/port.md#exposing-privileged-ports
* You will also want to change the sock path with the following command. `export DOCKER_HOST=unix:///run/user/1000/docker.sock`
2. **Other Systems** You will need to have docker installed and running.
```bash
docker run --rm -it alpine apk add openssl && openssl rand -hex 32
```
Add it to your `.env` file:
```dotenv
DB_PASSWORD="<your key>"
```
6. Generate your redis password:
```bash
docker run --rm -it alpine apk add openssl && openssl rand -hex 20
```
Add it to your `.env` file:
```dotenv
REDIS_PASSWORD="<your key>"
```
7. Generate an application key:
```bash
docker compose -f docker-compose.local.yml run --rm --entrypoint '' platform.test php artisan key:generate --show
```
Add it to your `.env` file:
```dotenv
APP_KEY="<your key>"
```
8. Alter the numerical IDs that PHP will run as in the application container:
Reason: your local directories will be mapped into the application container to allow your changes to be viewed in real time.
Find your local user ID & GROUP (Linux & MacOS):
```bash
ls -ln
```
You will see output like below. In the below case user is `1000` and group id is `1001`.
```bash
total 1124
drwxr-xr-x 18 1000 1001 4096 Mar 20 12:56 app
-rwxr-xr-x 1 1000 1001 1686 Nov 2 12:10 artisan
```
Add them to your `.env` file:
```dotenv
WWWUSER=<your user id>
WWWGROUP=<your group id>
```
9. Re-build you application container after the `.env` file updates:
```bash
docker compose -f docker-compose.local.yml build platform.test
```
10. Start up the entire stack:
```bash
docker compose -f docker-compose.local.yml up -d
```
11. If you are going to be committing code changes you will want to copy the php packages from the container and install node packages.
```bash
docker cp platform.test:/app/vendor ./vendor
nvm use
npm ci
```
For comprehensive instructions, consult the [Laravel documentation](https://laravel.com/docs/10.x). Here's an overview of how some key tasks can be carried out using your containers:

- Visit the site using the SSL proxy to make sure assets load [https://localhost](https://localhost).
- [Artisan](https://laravel.com/docs/10.x/artisan) commands may be executed by using `docker exec --user www-data platform.test php artisan <command>`.
- [NPM](https://docs.npmjs.com/cli/v7) commands may be executed by using `docker exec --user www-data platform.test npm <command>`.
- [Composer](https://getcomposer.org) commands may be executed by using `docker exec --user www-data platform.test composer <command>`.
- !(preferred way) If you want to enter the container to run commands as **www-data** user (which is best when the command will create files) then use `docker exec --user www-data -it platform.test bash`.
- If you want to enter the container to run commands as **root** user then use `docker exec -it platform.test bash`.

#### Troubleshooting

**Changes are missing in the container**

- Rebuild the container and relaunch with the following command `docker compose -f docker-compose.local.yml build platform.test && docker compose -f docker-compose.local.yml up -d`.

**Cannot reach site using browser**

- Check that all containers are up and running using the following command `docker ps -a` and check for container with the name `platform.test` and check the status column to see if it says **Up**.
- If it's not up then try to check logs to see if there is an error with the command `docker compose -f docker-compose.local.yml logs -f platform.test`. This should help you resolve what might be missing.
### Local development using Docker and Nix
1. Install [Nix](https://nixos.org/download/) for your system.
2. Run `nix-shell`.
3. If you are wanting to run dockers then follow the steps for your platform.
1. **Linux** On linux there are added aliases `dstart` & `dstop` that will start and stop the docker daemon which will run using rootlesskit.
* When using rootless you will want to make sure that Rootless is setup and allowed to run on priveleged ports. https://github.com/rootless-containers/rootlesskit/blob/master/docs/port.md#exposing-privileged-ports
* You will also want to change the sock path with the following command. `export DOCKER_HOST=unix:///run/user/1000/docker.sock`
2. **Other Systems** You will need to have docker installed and running.
#### Available helpful aliases
#### Available helpful aliases
| alias | description |
| --- | ------- |
Expand All @@ -341,7 +207,7 @@ For comprehensive instructions, consult the [Laravel documentation](https://lara
| `kcs` | `kubectl` command for the **staging** namespace |
| `kcp` | `kubectl` command for the **production** namespace |
*These aliases are loaded only on linux systems
*These aliases are loaded only on linux systems
#### Troubleshooting
Expand All @@ -351,6 +217,7 @@ For comprehensive instructions, consult the [Laravel documentation](https://lara
**Cannot reach site using browser**
- Visit the site using the SSL proxy to make sure assets load [https://localhost](https://localhost).
- Check that all containers are up and running using the following command `docker ps -a` and check for container with the name `platform.test` and check the status column to see if it says **Up**.
- If it's not up then try to check logs to see if there is an error with the command `dc logs -f platform.test`. This should help you resolve what might be missing.

Expand Down

0 comments on commit c7a8fb7

Please sign in to comment.