Creating a custom Dockerfile

Created by Steve Place, Modified on Wed, May 7 at 11:02 AM by Steve Place

If you need to customize your Stardog image (to use different drivers, development versions, etc.) you can create a custom Dockerfile. 


Below is an example StardogDockerfile that pulls the latest Stardog image and installs the MySQL driver:

ARG STARDOG_SERVER_IMAGE=stardog/stardog:latest
FROM $STARDOG_SERVER_IMAGE

USER root

RUN mkdir -p /var/opt/drivers
RUN mkdir -p /var/opt/stardog-backups

RUN apt update -y
RUN apt install -y sudo unzip


# Install MySQL Driver
RUN curl -L -o /tmp/mysql-connector.zip https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.30.zip \
    && unzip -j /tmp/mysql-connector.zip "*.jar" -d "/var/opt/drivers/" \
    && rm -rf /tmp/mysql-connector.zip

RUN chown -R stardog:stardog /var/opt/drivers
RUN chown -R stardog:stardog /var/opt/stardog
# As of helm-chart-sa 3.3.0, we run the container as UID 10000 (this is modifiable) 
# to remove risk of UID overlap between the container and the VM. 
chmod -R 744 /var/opt/drivers

ENV PATH="/opt/stardog/bin:$PATH"
ENV STARDOG_EXT=/var/opt/drivers

USER stardog

To get started, save your custom StardogDockerfile in your working directory. Below are commands to build the image and push it to various container registries:


Azure Container Registry (ACR)


az acr build --image $STARDOG_IMAGE:${STARDOG_VERSION}-1.0 --registry $ACR_NAME --file StardogDockerfile .


Docker


First, build the Docker image locally:

docker build -t $STARDOG_IMAGE:${STARDOG_VERSION}-1.0 -f StardogDockerfile .


Then, push the Docker image to Docker Hub (ensure you're logged in first with docker login):

docker push $STARDOG_IMAGE:${STARDOG_VERSION}-1.0


AWS Elastic Container Registry (ECR)


Authenticate Docker to your Amazon ECR registry:

aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com


Build and tag the Docker image:

docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$STARDOG_IMAGE:${STARDOG_VERSION}-1.0 -f StardogDockerfile .


Push the Docker image to Amazon ECR:

docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$STARDOG_IMAGE:${STARDOG_VERSION}-1.0



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article