Code Monkey home page Code Monkey logo

st2packs-dockerfiles's Introduction

Go to Docker Hub

Overview

By default, only system packs are available to StackStorm services when installed using the stackstorm-ha helm chart. If you need additional packs, bake them into a custom docker image using the instructions below.

The st2packs image will mount /opt/stackstorm/{packs,virtualenvs} via a sidecar container in pods which need access to the packs. These volumes are mounted read-only. In the kubernetes cluster, the st2 pack install command will not work.

Building the st2packs image

To build your own custom st2packs image, run:

git clone [email protected]:stackstorm/st2packs-dockerfiles
cd st2packs-dockerfiles
docker build --build-arg PACKS="<pack names>" -t ${DOCKER_REGISTRY}/st2packs:<version_number> st2packs-image

where <pack names> is a space separated list of packs you want to install in the st2packs image and <docker_registry> is the registry URL. <version_number> should be used and incremented with each change to the pack contents, since using 'latest' as the pack will not tell helm when changes occur and upgrade will not occur. The pack may be specified as a github url, or as a local file (e.g. file://). In the latter case, then you need to ensure these are COPY'd into the docker build environment. As an example,

ARG PACKS="file:///tmp/stackstorm-st2"

FROM stackstorm/st2packs:builder AS builder
# considering you have your "local" pack under the `stackstorm-st2` dir relative to Dockerfile
# Here we copy local "stackstorm-st2" dir into Docker's "/tmp/stackstorm-st2"
COPY stackstorm-st2 /tmp/stackstorm-st2/
# Check it
RUN ls -la /tmp/stackstorm-st2

RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}
FROM stackstorm/st2packs:runtime

Helper images

The st2packs-builder and st2packs-runtime directories each contain a Dockerfile for images that are used to simplify the st2packs Dockerfile.

st2packs-dockerfiles's People

Contributors

airavichandra avatar aliasboink avatar arm4b avatar armab avatar cmmdrdata avatar cognifloyd avatar cydergoth avatar danielburrell avatar hreeder avatar warrenvw avatar xelinor avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

st2packs-dockerfiles's Issues

python3 virtualenv for st2 pack

Hi,

I've packs running on standalone stackstrom which I install using command

st2 pack install <pack> --python3

But as per the doc there is nothing to use python3, I'm on Centos7 and installed both python2 & 3 but by default it's using python2.

RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}

I tried changing this command but it didn't work. Is there any way I can run my custom pack with python3.

Any help would be appreciated, thanks in advance!

allow pack installation by ssh

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v [email protected]:mypack/pack.git /root/aeb9eb941cfeeb0092a071ee94b4783d
  stderr: 'Cloning into '/root/aeb9eb941cfeeb0092a071ee94b4783d'...
fatal: cannot run ssh: No such file or directory
fatal: unable to fork

the pack-install script should support cloning packs from git over ssh

arma [11 minutes ago]
Sounds like we'll need ssh client installed which is most probably absent in `builder` Docker image: https://github.com/StackStorm/st2packs-dockerfiles/blob/master/st2packs-builder/Dockerfile

custom pack doesn't run on Stackstorm v3.2.0

We built a custom pack docker image from stackstorm/st2packs (https://hub.docker.com/r/stackstorm/st2packs). Then we integrate that customized image into Stackstorm HA helm chart v3.2.0. When running actions from the custom pack, getting this error.
"/opt/stackstorm/virtualenvs/captain/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /opt/stackstorm/virtualenvs/captain/bin/python)"

it appears that stackstorm/st2packs image is on Ubuntu 18.04.4. StackStorm v3.2.0 is running on Ubunto 16.0.4. Due to the ubunto version diff, the above error occurs.

stackstorm/st2packs has 2 tags: builder, runtime. It doesn't have tag in versions so we can go back to older version.
How can we get stackstorm/st2pack image on ubuntu 16.0.4 and python3 on it because our pack is written in python3 ?

Thanks

issues using packs mounted from a second container

Tried to create a custom st2pack image, but have run into a number of issues.

Firstly, using the alpine 3.8 based image I created an image, however when trying to mount a volume inside the st2 container sensors wouldn't start:

root@stackstorm-i-01400f9ceacafe90e:/# /opt/stackstorm/virtualenvs/kubernetes/bin/python
bash: /opt/stackstorm/virtualenvs/kubernetes/bin/python: No such file or directory
root@stackstorm-i-01400f9ceacafe90e:/# ldd /opt/stackstorm/virtualenvs/kubernetes/bin/python
    linux-vdso.so.1 =>  (0x00007ffd00d6a000)
    libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007fe9c7949000)
    libc.musl-x86_64.so.1 => not found

Working on the assumption there's a mismatch between alpine libc (which uses musl-libc) and ubuntu trusty which uses glibc, I copied the python binary into one of the virtualenvs. This worked, however was missing a bunch of python libraries (oslo.config then st2common - i didn't keep installing them to see how many).

At this point I created an ubuntu trusty based st2pack image, and this starts up, however sensors are failing

2018-10-01 13:14:22,180 INFO [-] Sensor kubernetes.watchExtensionsV1beta1DeploymentListForAllNamespaces started
2018-10-01 13:14:22,180 DEBUG [-] 1 active sensor(s)
/opt/stackstorm/st2/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
  utils.DeprecatedIn23,
2018-10-01 13:14:23,067 INFO [-] Found config for sensor "watchExtensionsV1beta1DeploymentListForAllNamespaces"
2018-10-01 13:14:23,068 DEBUG [-] Connecting to Kubernetes endpoint https://master.andy2.eu-west-1.dev/apis/extensions/v1beta1/watch/deployments via api_client.
2018-10-01 13:14:23,068 INFO [-] Watcher started
2018-10-01 13:14:23,068 INFO [-] Running sensor initialization code
2018-10-01 13:14:23,069 DEBUG [-] Connecting to Kubernetes endpoint https://master.andy2.eu-west-1.dev/apis/extensions/v1beta1/watch/deployments via api_client.
2018-10-01 13:14:23,069 INFO [-] Running sensor in passive mode
2018-10-01 13:14:23,069 INFO [-] Watch /apis/extensions/v1beta1/watch/deployments for new data.
2018-10-01 13:14:23,076 WARNING [-] Sensor "watchExtensionsV1beta1DeploymentListForAllNamespaces" run method raised an exception: [('system library', 'fopen', 'No such file or directory'), ('BIO routines', 'file_ctrl', 'system lib'), ('SSL routines', 'SSL_CTX_use_certificate_file', 'system lib')].
Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/container/sensor_wrapper.py", line 223, in run
    self._sensor_instance.run()
  File "/opt/stackstorm/packs/kubernetes/sensors/sensor_base.py", line 83, in run
    certfile=self.config['client_cert_path'])
  File "/opt/stackstorm/virtualenvs/kubernetes/local/lib/python2.7/site-packages/backports/ssl/core.py", line 689, in wrap_socket
    ctx.load_cert_chain(certfile, keyfile)
  File "/opt/stackstorm/virtualenvs/kubernetes/local/lib/python2.7/site-packages/backports/ssl/core.py", line 659, in load_cert_chain
    self._ctx.use_certificate_file(certfile)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/OpenSSL/SSL.py", line 935, in use_certificate_file
    _raise_current_error()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
Error: [('system library', 'fopen', 'No such file or directory'), ('BIO routines', 'file_ctrl', 'system lib'), ('SSL routines', 'SSL_CTX_use_certificate_file', 'system lib')]
2018-10-01 13:14:23,078 ERROR [-] Traceback (most recent call last):

2018-10-01 13:14:23,079 ERROR [-]   File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/container/sensor_wrapper.py", line 355, in <module>

The dockerfile i've used for this is as follows:

FROM ubuntu:trusty AS builder

RUN apt-get update \
  && apt-get install -y software-properties-common \
  && add-apt-repository ppa:strukturag/libressl \
  && apt-get update \
  && apt-get install -y python python-pip \
  && pip install --upgrade pip setuptools \
  && pip install GitPython lockfile virtualenv \
  && apt-get install -y \
    gcc \
    git \
    libffi-dev \
    libressl-dev \
    linux-headers-generic \
    make \
    musl-dev \
    python-dev \
    sudo

RUN python -m pip install -U "pip<10"

# Add st2common (orquesta must be installed separately otherwise there is an error when installing st2common)
RUN pip install -e git+https://github.com/StackStorm/orquesta.git@master#egg=orquesta
RUN pip install -e git+https://github.com/StackStorm/st2#egg=st2common\&subdirectory=st2common

RUN ln -s /usr/local/bin/virtualenv /usr/bin/virtualenv

# Before running st2-pack-install, ensure a basic st2.conf file exists and ARG PACKS is available
RUN mkdir -p /etc/st2
COPY files/st2.conf /etc/st2/st2.conf

ADD packs /packs

# Install custom packs
{% for pack in packlist %}
RUN /usr/local/bin/st2-pack-install {{ pack }}
{%- endfor %}

{% for pack in corelist %}
ADD packdefaults/{{ pack }} /opt/stackstorm/packs/{{ pack }}
{% endfor -%}

###########################
# Minimize the image size. Start with alpine:3.8,
# and add only packs and virtualenvs from builder.
FROM stackstorm/st2packs:runtime

ADD files/st2.d /st2-docker/st2.d
ADD files/entrypoint.d /st2-docker/entrypoint.d

RUN find /st2-docker
RUN ls -l /opt/stackstorm/packs

CMD tail -f /dev/null

In summary, I think there's probably 2-3 issues here in terms of getting a container loaded just with packs to work alongside the main stackstorm image. Have also had to add default packs (core, st2, chatops, packs and default) separately because of pack and virtualenv directory overlaps

Add CI

Setup CI to build & deploy st2packs-builder and st2packs-runtime to docker hub.

/opt/stackstorm/virtualenvs/{pack} does not exist

I am trying to build custom pack image. however keep getting this message
/opt/stackstorm/virtualenvs/{pack} does not exist

example 1

$ docker build --build-arg PACKS="csv" --tag st2packs:temp  st2packs-image
Sending build context to Docker daemon  4.608kB
Step 1/3 : FROM stackstorm/st2packs:builder AS builder
# Executing 2 build triggers
 ---> Using cache
 ---> Running in 21ed0b91a229
Removing intermediate container 21ed0b91a229
 ---> 687ff0be7f30
Step 2/3 : RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}
 ---> Running in 9f6fbd0878ec
2021-02-03 15:58:20,109 INFO [-] Installing pack "csv"
2021-02-03 15:58:21,729 INFO [-] Successfully installed pack "csv"
2021-02-03 15:58:21,729 INFO [-] Setting up virtualenv for pack "csv"
2021-02-03 15:58:21,730 INFO [-] Virtualenv path "/opt/stackstorm/virtualenvs/csv" doesn't exist
2021-02-03 15:58:27,714 INFO [-] Successfully set up virtualenv for pack "csv"
Removing intermediate container 9f6fbd0878ec
 ---> 6caf196701ef
Step 3/3 : FROM stackstorm/st2packs:runtime
# Executing 3 build triggers
 ---> Using cache
 ---> 14bfee293f14
Successfully built 14bfee293f14
Successfully tagged st2packs:temp

example 2

$ docker build --build-arg PACKS="git" --tag st2packs:temp  st2packs-image
Sending build context to Docker daemon  4.608kB
Step 1/3 : FROM stackstorm/st2packs:builder AS builder
# Executing 2 build triggers
 ---> Using cache
 ---> Running in 1f0d2129905e
Removing intermediate container 1f0d2129905e
 ---> 15701667e076
Step 2/3 : RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}
 ---> Running in f1056a493fb9
2021-02-03 16:23:40,633 INFO [-] Installing pack "git"
2021-02-03 16:23:42,382 INFO [-] Successfully installed pack "git"
2021-02-03 16:23:42,383 INFO [-] Setting up virtualenv for pack "git"
2021-02-03 16:23:42,384 INFO [-] Virtualenv path "/opt/stackstorm/virtualenvs/git" doesn't exist
2021-02-03 16:23:49,616 INFO [-] Successfully set up virtualenv for pack "git"
Removing intermediate container f1056a493fb9
 ---> 7891e85cdeee
Step 3/3 : FROM stackstorm/st2packs:runtime
# Executing 3 build triggers
 ---> Using cache
 ---> ad54b3db93ed
Successfully built ad54b3db93ed
Successfully tagged st2packs:temp

file:/// syntax still expects git repo?

So st2packs-dockerfiles accepts local files/packs using the following format file:///tmp/packs/cassandra .. but apparently it still expects them to be a git repo as it fails:

2019-09-27 11:53:14,629 INFO [-] Installing pack "file:///tmp/packs/cassandra"

# cut for brevity...

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v file:///tmp/packs/cassandra /root/0bd83c56596f6797b1a4c509296a3e7e
  stderr: 'Cloning into '/root/0bd83c56596f6797b1a4c509296a3e7e'...
fatal: '/tmp/packs/cassandra' does not appear to be a git repository
fatal: Could not read from remote repository.

Add CI/CD

Docker Hub removed free builds which we used for this repository to automatically build and push the images to https://hub.docker.com/r/stackstorm/st2packs/tags.

Since the feature is not available anymore, add CI/CD with Github Actions to build and push the images to Docker Hub for every update/push to the master.

Different output when using buildx vx. build

This command works fine and generates an image in ~1.3 Gb

docker build --build-arg PACKS="aws csv email excel git github gpg hubot vault xml" -t st2packs:1.0.5 st2packs-image

I am using Github Action and it uses docker buildx build command.

docker buildx build --build-arg PACKS="aws csv email excel git github gpg hubot vault xml" --tag st2packs:1.0.4 st2packs-image

This only produces 4Mb docker image with no packs copied.

Getting error when building custom image with 'ansible' pack added.

  • I'm trying to build custom pack image with 'ansible' pack added. But keep getting this error message:
Building wheels for collected packages: pykerberos
  Building wheel for pykerberos (setup.py): started
  Building wheel for pykerberos (setup.py): finished with status 'error'
  Running setup.py clean for pykerberos
Failed to build pykerberos
Installing collected packages: pycparser, urllib3, idna, charset-normalizer, cffi, certifi, requests, pyparsing, ntlm-auth, MarkupSafe, cryptography, xmltodict, resolvelib, requests-ntlm, PyYAML, pyspnego, packaging, jinja2, requests-credssp, pywinrm, pykerberos, ansible-core, netaddr, ansible
    Running setup.py install for pykerberos: started
    Running setup.py install for pykerberos: finished with status 'error'
 (stderr:   ERROR: Command errored out with exit status 1:
   command: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-iyp_di66
       cwd: /tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/
  Complete output (10 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'kerberos' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/opt/stackstorm/virtualenvs/ansible/include -I/usr/include/python3.8 -c src/kerberos.c -o build/temp.linux-x86_64-3.8/src/kerberos.o
  unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pykerberos
    ERROR: Command errored out with exit status 1:
     command: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-uqi43b55/install-record.txt --single-version-externally-managed --compile --install-headers /opt/stackstorm/virtualenvs/ansible/include/site/python3.8/pykerberos
         cwd: /tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/
    Complete output (10 lines):
    running install
    running build
    running build_ext
    building 'kerberos' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/opt/stackstorm/virtualenvs/ansible/include -I/usr/include/python3.8 -c src/kerberos.c -o build/temp.linux-x86_64-3.8/src/kerberos.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-uqi43b55/install-record.txt --single-version-externally-managed --compile --install-headers /opt/stackstorm/virtualenvs/ansible/include/site/python3.8/pykerberos Check the logs for full command output.
  • After some diggin' around, i've found this issue and begin to suspect that there was some missing dependencies here. I was right, libkrb5-dev gcc python3-dev python-dev were missing.
  • I did some simple, temporary workaround for this. What i did was add those missing dependencies directly into the builder Dockerfile using sed.
    sed -i "2i RUN apt update && apt install -y libkrb5-dev gcc python3-dev python-dev && rm -rf /var/lib/apt/lists/*" ./st2packs-image/Dockerfile
  • And then proceed to build the image as the docs says. Summary for everything i've did:
$ git clone [email protected]:stackstorm/st2packs-dockerfiles
$ cd st2packs-dockerfiles
$ sed -i "2i RUN apt update && apt install -y libkrb5-dev gcc python3-dev python-dev && rm -rf /var/lib/apt/lists/*" ./st2packs-image/Dockerfile
$ docker build --build-arg PACKS="ansible" -t ${DOCKER_REGISTRY}/st2packs:<version_number> st2packs-image
  • I hope this could help and if anyone has better idea/way feel free to add. I'd really appreciate it.

Example using st2packs

It would be nice with an example of how to use the finisded st2pack Image. Right now I'm running a docker swarm and I have a hard time seeing how I would incorporate the st2pack image in my deployment. Do I have to start using kubernetes?

How to install packs behind proxy while building st2packs image

Hi there,

I've tested installing packs behind a proxy in a ss installed on RHEL and it works well.
But in ss-ha how to install packs with proxy and build image?

E.G. to build image with internet access to install azure is easy:

git clone [email protected]:stackstorm/st2packs-dockerfiles
cd st2packs-dockerfiles
docker build --build-arg PACKS="azure" -t myregistry.com/st2packs:1.0 st2packs-image

However we cannot change /etc/default/st2actionrunner and /etc/default/st2api as installing-packs-from-behind-a-proxy described in the image.

st2packs-image - docker multi stage build issue - builder stage being missed on MacOS

Summary

I've run into an issue in which the Docker multi stage build seems to be exhibiting unexpected / undesirable behavior which is causing issues for st2packs usage.

Related Issue from buildkit moby/buildkit#816

In short;
The build instructions for the builder stage are being ignored when using the suggested docker build --build-arg PACKS="<pack names>" -t ${DOCKER_REGISTRY}/st2packs:<version_number> st2packs-image command.

Issue visualized

command
docker build --no-cache --build-arg PACKS="aws" -t awildphil/st2packs:1 st2packs-image --progress plain

build logs

#5 [stage-1 1/1] FROM docker.io/stackstorm/st2packs:runtime@sha256:33f4e77bdd2e942750d8631668ccc9973f12719dac96dc4081e99d30934da69c
#5 sha256:b7b5e5061b2c1f6102a7ceb5a5b42cd04647ab3b4140999a86bf506c600932c2
#5 CACHED

#6 [builder 1/2] FROM docker.io/stackstorm/st2packs:builder
#6 sha256:44de4ae3067832ab1ea2ff2f56e09f71e5584def8b5dc65a88d2a3575cb9ffec
#6 resolve docker.io/stackstorm/st2packs:builder
#6 resolve docker.io/stackstorm/st2packs:builder 0.1s done
#6 CACHED

#7 [stage-1 2/1] COPY --from=builder /opt/stackstorm/packs /opt/stackstorm/packs
#7 sha256:970c29dc5d40e0837a8c2af438f84d250263de882d5c801f4ccfb4022553efd7
#7 DONE 0.1s

#8 [stage-1 3/1] COPY --from=builder /opt/stackstorm/virtualenvs /opt/stackstorm/virtualenvs
#8 sha256:401b19f099d43eee608d293d3d89e8819cb5a91936ef477aad41895932db733c
#8 DONE 0.0s

#9 exporting to image
#9 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#9 exporting layers 0.0s done
#9 writing image sha256:9aaa0ce7359a099526b6af1f8de0cc5420caf3de986c1b1c516a3d23d0555845 done
#9 naming to docker.io/awildphil/st2packs:1 done
#9 DONE 0.1s

container logs

[Bitovi] [st2packs-dockerfiles] $ docker run --rm -it awildphil/st2packs:1 sh
/ # ls /opt/stackstorm/
packs        virtualenvs
/ # ls /opt/stackstorm/packs/
chatops  core     default  linux    packs

As you can see;

  1. The st2-pack-install command wasn't invoked by the build
  2. The aws pack is not where we expect it.

Fix

By adding the following COPY instructions to the bottom of the Dockerfile we get the expected behavior.

st2pack-image/Dockerfile

... previously committed
FROM stackstorm/st2packs:runtime

COPY --from=builder /opt/stackstorm/packs /opt/stackstorm/packs 
COPY --from=builder /opt/stackstorm/virtualenvs /opt/stackstorm/virtualenvs

command
export DOCKER_BUILDKIT=1; docker build --no-cache --build-arg PACKS="aws" -t awildphil/st2packs:1 st2packs-image --progress plain

build logs

#8 [builder 3/2] RUN /opt/stackstorm/st2/bin/st2-pack-install aws
#8 sha256:5963ceb010683f1dc760d801db7dc8a7ce541630a9a38b543c18bd602cad41be
#8 0.860 2022-11-30 19:06:22,708 INFO [-] Installing pack "aws"
#8 2.964 2022-11-30 19:06:24,812 INFO [-] Successfully installed pack "aws"
#8 2.964 2022-11-30 19:06:24,812 INFO [-] Setting up virtualenv for pack "aws"
#8 2.964 2022-11-30 19:06:24,813 INFO [-] Virtualenv path "/opt/stackstorm/virtualenvs/aws" doesn't exist
#8 12.22 2022-11-30 19:06:34,066 INFO [-] Successfully set up virtualenv for pack "aws"
#8 DONE 12.9s

#9 [stage-1 2/3] COPY --from=builder /opt/stackstorm/packs /opt/stackstorm/packs
#9 sha256:71bfca09a805a8b2ba11a26da5448bc170bf01f9f16bdd446b9d9e73a7aa926a
#9 DONE 0.6s

#10 [stage-1 3/3] COPY --from=builder /opt/stackstorm/virtualenvs /opt/stackstorm/virtualenvs
#10 sha256:8fcf9cbc9a88f30980d86e1268518e913d1cbef4ef37b5eede94e0c70034d9de
#10 DONE 0.7s

#11 [stage-1 4/3] COPY --from=builder /opt/stackstorm/packs /opt/stackstorm/packs
#11 sha256:abbb9ea4e1266b0ba7d1802a4fb9a2c24e865a010a49012291621fa29d37bda2
#11 DONE 0.7s

#12 [stage-1 5/3] COPY --from=builder /opt/stackstorm/virtualenvs /opt/stackstorm/virtualenvs
#12 sha256:94915dd090c49db3f5d15b226f8921d7f2d7fcdbe0cba7f4523980c5ee44ddb0
#12 DONE 1.0s

container logs

[Bitovi] [st2packs-dockerfiles] $ docker run --rm -it awildphil/st2packs:1 sh
/ # ls /opt/stackstorm/packs/
aws      chatops  core     default  linux    packs

Solution 2

command
export DOCKER_BUILDKIT=0; docker build --no-cache --build-arg PACKS="aws" -t awildphil/st2packs:1 st2packs-image --progress plain

Details

Docker Version: Docker version 20.10.7, build f0df350
OS Version: {
Big Sur - v11.6.4
Processor: 2.6 GHz 6-Core Intel Core i7
Memory: 32 GB 2667 MHz DDR4
}

Getting Error while running packs /lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.29' Not found

We are deploying custom packs in AKS using Helm and custom pack image is build using below docker file:
dockerfile:

FROM stackstorm/st2packs:builder AS builder
COPY stackstorm-st2 /tmp/stackstorm-st2/
RUN ls -la /tmp/stackstorm-st2
RUN /opt/stackstorm/st2/bin/st2-pack-install file:///tmp/stackstorm-st2/custom_pack
FROM stackstorm/st2packs:runtime

We are running pipeline to build docker image and then running BlackDuck scan and finally deploying in AKS.
Till 20 Sep 2022 is was working as expected and from 22 Sep 2022 onwards we started getting below error when running packs:
{
"stdout": "",
"stderr": "/opt/stackstorm/virtualenvs/custome_pack/bin/python: /lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.29' Not found" (required by /opt/stackstorm/virtualenvs/custome_pack/bin/python)\n/opt/stackstorm/virtualenvs/custome_pack/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.28' Not found (required by /opt/stackstorm/virtualenvs/custome_pack/bin/python)\n,
"exit_code":1,
""result": "None"
}

In order to analyze it we deployed the same custom pack(Image build with same packs) build before 21st September its not giving any error however when we rebuild the same code and create new image, post deployment of the newly created image packs start giving error as mentioned above.

One more thing even our BlackDuck scan started failing for the newly created Images.

as we using below image in order to create custom Image, We suspect some issue with this image:
stackstorm/st2packs:builder
stackstorm/st2packs:runtime

Could someone please help me for this.

st2-pack-install fails on cloned pack that has been checked out to a branch

this works - checked out master

Step 8/34 : RUN /usr/bin/st2-pack-install file:///packs/aws_efs
 ---> Running in 22cd6435982b
2018-09-27 22:47:23,908 INFO [-] Installing pack "file:///packs/aws_efs"
2018-09-27 22:47:25,808 INFO [-] Successfully installed pack "aws_efs"
2018-09-27 22:47:25,809 INFO [-] Setting up virtualenv for pack "aws_efs"
2018-09-27 22:47:25,810 INFO [-] Virtualenv path "/opt/stackstorm/virtualenvs/aws_efs" doesn't exist
2018-09-27 22:48:19,936 INFO [-] Successfully set up virtualenv for pack "aws_efs"
Removing intermediate container 22cd6435982b

This fails - checked out a branch

Step 9/34 : RUN /usr/bin/st2-pack-install file:///packs/consul
 ---> Running in 089d41bf34d7
2018-09-27 22:48:24,542 INFO [-] Installing pack "file:///packs/consul"
Traceback (most recent call last):
  File "/usr/bin/st2-pack-install", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/src/st2common/st2common/bin/st2-pack-install", line 42, in <module>
    sys.exit(install_pack.main(sys.argv[1:]))
  File "/src/st2common/st2common/st2common/cmd/install_pack.py", line 66, in main
    proxy_config=proxy_config, force_permissions=True)
  File "/src/st2common/st2common/st2common/util/pack_management.py", line 119, in download_pack
    ref=pack_version)
  File "/src/st2common/st2common/st2common/util/pack_management.py", line 154, in clone_repo
    active_branch = repo.active_branch
  File "/usr/lib/python2.7/site-packages/git/repo/base.py", line 696, in active_branch
    return self.head.reference
  File "/usr/lib/python2.7/site-packages/git/refs/symbolic.py", line 275, in _get_reference
    raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '96ccf2ec68fd52680bade668ccced67c4a77e102'
ERROR: Service 'image-st2pack' failed to build: The command '/bin/sh -c /usr/bin/st2-pack-install file:///packs/consul' returned a non-zero code: 1

Provide better documentation about installing from "local pack" via file:///

As reported in #community

When installing a pack from "local dir", need to make sure that path is available during the docker build environment. It means it needs additional COPY operation prior to running st2-pack-install.

An example Dockerfile that demonstrates it:

ARG PACKS="file:///tmp/stackstorm-st2"

FROM stackstorm/st2packs:builder AS builder
# considering you have your "local" pack under the `stackstorm-st2` dir relative to Dockerfile
# Here we copy local "stackstorm-st2" dir into Docker's "/tmp/stackstorm-st2"
COPY stackstorm-st2 /tmp/stackstorm-st2/
# Check it
RUN ls -la /tmp/stackstorm-st2

RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}
FROM stackstorm/st2packs:runtime

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.