How to keep PHPUnit up to date in Docker / Devilbox? - docker

I am using Devilbox LAMPstack as my development environment. It ships with PHPUnit v 7.x, which I can update by doing this:
$ wget https://phar.phpunit.de/phpunit.phar
$ chmod +x phpunit.phar
$ sudo mv phpunit.phar /usr/local/bin/phpunit
This gets me to the latest version of PHPUnit (currently 9.x). Of course it does not persist if I run docker-compose down or docker-compose rm -f, as is recommended on Devilbox.
I'm very new to Docker / Devilbox. My question is, is there a permanent way to get the updated version of PHPUnit to persist?

Related

How to setup dbt using docker containers on Windows 10

After reading Dbt documentation, I've had a hard time to figure out how to install dbt-core (or any other packages i.e. dbt-postgres, dbt-snowflake, etc) on Windows 10.
I have Docker Desktop installed, running a couple of containers already (mostly nodeJS containers, and Kafka). However, it was hard to understand how I would have those new Dbt containers available in my Docker Desktop Console.
I can see docker images were installed properly
$docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
**ghcr.io/dbt-labs/dbt-core 1.2.1 802a0d70aedc 4 weeks ago 538MB**
**ghcr.io/dbt-labs/dbt-bigquery 1.2.latest b7502bcd3b35 2 months ago 559MB**
...
postgres latest f8dd270e5152 7 weeks ago 376MB
dpage/pgadmin4 latest d13c9d7d0193 2 months ago 382MB
wurstmeister/kafka latest a692873757c0 4 months ago 468MB
wurstmeister/zookeeper latest 3f43f72cb283 3 years ago 510MB
Does anyone know how to I them to the Desktop Console?
I'm currently on Windows 10 and use a Docker image for my dbt project without needing WSL. Below is my Dockerfile and requirements.txt file with dbt-core and dbt-snowflake but feel free to swap the packages you need.
In my repo, my dbt project is in a folder at the root level named dbt.
requirements.txt
dbt-core==1.1.0
dbt-snowflake==1.1.0
Dockerfile
FROM public.ecr.aws/docker/library/python:3.8-slim-buster
COPY . /dbt
# Update and install system packages
RUN apt-get update -y && \
apt-get install --no-install-recommends -y -q \
git libpq-dev python-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install dbt
RUN pip install -U pip
RUN pip install -r dbt/requirements.txt
# TEMP FIX due to dependency updates. See https://github.com/dbt-labs/dbt-core/issues/4745
RUN pip install --force-reinstall MarkupSafe==2.0.1
# Install dbt dependencies
WORKDIR /dbt
RUN dbt deps
# Specify profiles directory
ENV DBT_PROFILES_DIR=.dbt
# Expose port for dbt docs
EXPOSE 8080
And then you can build and run it (I personally put both of these commands in a dbt_run.sh file and run with bash dbt_run.sh):
docker build -t dbt_image .
docker run \
-p 8080:8080 \
--env-file .env \
-it \
--mount type=bind,source="$(pwd)",target=/dbt \
dbt_image bash
If you make changes to your dbt project while the container is running they will be reflected in the container which makes it great for developing locally. Hope this helps!
I finally was able to pull the image. To add a container in the Docker desktop, I just needed to actually run it.
However, running a dbt-core container in docker, it returns an error:
right after I start the container it stops and returns exit(1), as per the screenshot.

upgrade 4.0.17 to 4.1 version

How to upgrade an earlier version to the latest?
I am running 4.0.17 (bitnami) version and trying to start using the latest 4.1 version. Platform Debian.
Unpack 4.1 files
CD into the folder and run composer update --no-dev
Copied .env file from 4.0.17 version backup
Install javascript assets using npm install
Compile javascript assets using npm run dev
Has anyone seen any upgrade steps? I am only getting error 500 in the browser. How to get access to detailed error logging to get more detailed error messages?
I was encountering similar issues when trying to upgrade the Processmaker 4 AMI to the latest version. After some trial and error and a bit of help from folks with experience in laravel, I seem to have resolved most issues with my processmaker upgrade. These are the full steps I used to upgrade the AMI:
sudo su - bitnami
cd /opt/bitnami
sudo wget https://github.com/ProcessMaker/processmaker/releases/download/v4.1.0/pm4.1.tar.gz
sudo ./ctlscript.sh stop
sudo mv processmaker/ processmaker-old/
sudo tar -xzvf pm4.1.tar.gz -C .
sudo cp processmaker-old/.env processmaker/
sudo cp processmaker-old/laravel-echo-server.json processmaker/
sudo cp /opt/bitnami/processmaker-old/storage/oauth-p* /opt/bitnami/processmaker/storage/
sudo cp -R /opt/bitnami/processmaker-old/storage/app/* /opt/bitnami/processmaker/storage/app/
sudo chown -R bitnami:daemon processmaker/
cd processmaker/
composer install --no-dev
npm install
npm run dev
sudo find /opt/bitnami/processmaker/ | sudo xargs sudo chmod a+w
php artisan migrate
sudo /opt/bitnami/ctlscript.sh start
My current sticking point is that previously uploaded media is not getting displayed on the site, but I am no longer getting errors with laravel-echo-server or MySQL.
Aside from the files which needed to be copied from the old installation (.env, laravel-echo-server.json, oauth keys and app data) The biggest hurdle for me here was php artisan migrate, which modifies tables in the processmaker database to support changes in laravel/processmaker.

Mounting docker volume on specific path

I am trying to deploy photo-stream (https://github.com/maxvoltar/photo-stream) using a docker container. Photo-stream is a picture publishing site meant for self-hosting. It expects its pictures in a path called 'photos/original/', relative to where it's installed. It will create other directories under 'photos/' to cache thumbnails and such.
When I populate that directory with some pictures and start the application natively (without docker) from its build directory using:
$ bundle exec jekyll serve --host 0.0.0.0
it shows me the pictures I put in that directory. When running the application inside a docker container, I need it to
mount a volume that contains a path 'photos/original' so that I can keep my pictures there. I have created this path on
a disk mounted at /mnt/data/.
In order to do that, I have added a volume line to the existing Dockerfile:
FROM ruby:latest
ENV VIPSVER 8.9.1
RUN apt update && apt -y upgrade && apt install -y build-essential
RUN wget -O ./vips-$VIPSVER.tar.gz https://github.com/libvips/libvips/releases/download/v$VIPSVER/vips-$VIPSVER.tar.gz
RUN tar -xvzf ./vips-$VIPSVER.tar.gz && cd vips-$VIPSVER && ./configure && make && make install
COPY ./ /photo-stream
WORKDIR /photo-stream
RUN ruby -v && gem install bundler jekyll && bundle install
VOLUME /photo-stream/photos
EXPOSE 4000
ENTRYPOINT bundle exec jekyll serve --host 0.0.0.0
I build the container this way:
$ docker build --tag photo-stream:1.0 .
I run the container this way:
$ docker run -d -p 4000:4000 -v /mnt/data/photos/:/photos/ --name ps photo-stream:1.0
I was expecting the content of the directory /mnt/data/photos to be shown. Instead, nothing is shown. However, a volume '/var/lib/docker/volumes/e5ff426ced2a5e786ced6b47b67d7dee59160c60f59f481516b638805b731902/_data' is created, and when that is populated with pictures, those are shown.

ERROR: Version in "./docker-compose.yml" is unsupported

I am running docker-compose build in a folder with the relevant docker files and yml files. I see the following error
root#ubuntu187_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker-compose build
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
The docker-compose.yml is as follows
# Basic IDOL container setup
# Uses nifi to ingest and index data into content
# Uses find to make search results available
# Default admin user is created for find in the community service
# - see community/run_community.sh for details
version: "3.7"
x-args-shared:
- &idol-version IDOL_VERSION=12.4.0 # version of IDOL components to use
# Change the IP to the address of an external IDOL LicenseServer instance
x-external-licenseserver-host: &external-licenseserver-host
- "idol-licenseserver:xx.xx.xx.xx"
# Shared volume configuration for nifi and view service - see volumes
x-idol-ingest-volume: &idol-ingest-volume
- idol-ingest-volume:/idol-ingest
#x-idol-categorisation-volume: &idol-categorisation-volume
# - idol-categorisation-volume:/idol-categorisation
# Shared volume in NiFi and View
# Any files dropped into this volume will be ingested and indexed
volumes:
idol-ingest-volume:
# idol-categorisation-volume:
services:
idol-content:
image: idol-compose/content
build:
context: ./content
args:
- *idol-version
extra_hosts: *external-licenseserver-host
ports:
- 9100:9100
docker-compose version
root#ubuntu18_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker-compose -version
docker-compose version 1.17.1, build unknown
docker version
root#ubuntu18_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker -v
Docker version 19.03.1, build 74b1e89
I can't change the version on the docker-compose.yml file.
I have resolved the issue using following steps
$ sudo apt-get remove docker-compose
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Your compose is too old, if you cannot change the version in compose, try to upgrade to latest docker-compose version
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Detail refers to this
The spec was updated in Compose v1.27 to merge the properties from version 2.x and 3.x compose files into a single format. The version property can still be included for legacy reasons but is no longer required and can be omitted if running the latest release of docker-compose.
The following script will update your installation on Ubuntu and solve the issue :
#!/bin/bash
sudo apt-get remove docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Using "sudo" the command works for me.
sudo docker-compose up
I did the following steps:
sudo apt-get remove docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
I hope this will resolve this issue.
Docker now officially supports compose so according to the documentation https://docs.docker.com/compose/install/compose-plugin/#install-using-the-repository use sudo apt-get install docker-compose-plugin then docker compose.
If you use sudo apt-get install docker-compose then docker-compose then you will end up with the older tool not supporting the newest format.

Creating first docker container: Can't find host system file on build

I'm trying to bundle my Jekyll blog as a docker container.
I found this Dockerfile which seems to suit my use case but wanted to be more hands on so I copied it directly into my repo:
FROM ruby:latest
MAINTAINER Peter Etelej <peter#etelej.com>
RUN apt-get -qq update && \
apt-get -qq install nodejs -y && \
gem install -q bundler
RUN mkdir -p /etc/jekyll && \
printf 'source "https://rubygems.org"\ngem "github-pages"\ngem "execjs"\ngem "rouge"' > /etc/jekyll/Gemfile && \
printf "\nBuilding required Ruby gems. Please wait..." && \
bundle install --gemfile /etc/jekyll/Gemfile --clean --quiet
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV BUNDLE_GEMFILE /etc/jekyll/Gemfile
EXPOSE 4000
ENTRYPOINT ["bundle", "exec"]
CMD ["jekyll", "serve","--host=0.0.0.0"]
When I run it I get an error
jekyll 3.4.3 | Error: No such file or directory # rb_sysopen - /etc/modules-load.d/modules.conf
The host system has this file but my assumption was that the container didn't have access to it so I tried to add it into the Dockerfile
ADD /etc/modules-load.d/modules.conf /etc/modules-load.d/modules.conf
I then docker build and get the error
lstat etc/modules-load.d/: no such file or directory
I don't understand why the container is looking for this file in the first place but I'm even more confused by the fact that I can't add a file which is clearly there.
Docker builds run on the docker host, not necessarily the client where you run the command, and so all the files needed to run the build are sent in the build context to the host. That context is most often the current directory, or ., that you pass at the end of the docker build -t $image_name . command.
Everything that you try to include in the image with a COPY or ADD is done in reference to that build context, not the filesystem on your client or host machine. So if you need a modules.conf, you'll need to first copy that into your directory with the Dockerfile, and then COPY the file from there.
As for why jekyll is looking for the file, I'm not familiar with jekyll, but it doesn't look promising for something running inside of a container. The modules are kernel specific and containers are designed to be moved to different hosts with potentially different kernels.

Resources