Example Dockerfile

Below is a example linux Docker container that installs a private runtime

Before you begin:

If your project is not private, then you won’t need to authenticate and you can simply use the following Dockerfile:

FROM ubuntu:24.04
ARG ACTIVESTATE_PROJECT
# Install curl, which is required by the state-tool installer
RUN apt -y update && apt -y install curl
# Install State Tool
RUN bash -c "sh <(curl -q https://platform.activestate.com/dl/cli/w19880m01/install.sh) /install.sh -n -t /opt/activestate/state-tool"
# Set up runtime and logout to avoid storing credentials in image
RUN /opt/activestate/state-tool/bin/state checkout ${ACTIVESTATE_PROJECT} --runtime-path /opt/activestate/runtime && \
    /opt/activestate/state-tool/bin/state use ${ACTIVESTATE_PROJECT} 
CMD ["bash"]

Your runtime executables will be located at /opt/activestate/runtime/exec.

Build your docker image with the ACTIVESTATE_PROJECT environment variable set to your project namespace, eg.

docker build -t myimg --build-arg="ACTIVESTATE_PROJECT=my/project" .

Authentication

When using private projects you will need to authenticate to source your runtime. In order to do this you will need to obtain an API key, and in order to do that you will need to have the State Tool installed locally.

To generate the API key you must first login:

state auth --prompt

Once logged in, you can create your API key (replace my-api-key-name with a name that is appropriate for your use-case):

ACTIVESTATE_API_KEY=$(state export new-api-key my-api-key-name)

Now use the following Dockerfile to build your image:

FROM ubuntu:24.04
ARG ACTIVESTATE_API_KEY
ARG ACTIVESTATE_PROJECT
# Install curl, which is required by the state-tool installer
RUN apt -y update && apt -y install curl
# Install State Tool
RUN bash -c "sh <(curl -q https://platform.activestate.com/dl/cli/w19880m01/install.sh) /install.sh -n -t /opt/activestate"
# Set up runtime and logout to avoid storing credentials in image
RUN /opt/activestate/bin/state auth --token ${ACTIVESTATE_API_KEY} && \
    /opt/activestate/bin/state checkout ${ACTIVESTATE_PROJECT} && \
    /opt/activestate/bin/state use ${ACTIVESTATE_PROJECT} && \
    /opt/activestate/bin/state auth logout
CMD ["bash"]

Now when building the Docker image, supply your project namespace as well as the generated API key:

docker build -t myimg --build-arg="ACTIVESTATE_PROJECT=my/project --build-arg="ACTIVESTATE_API_KEY=generated-key-value" .