Is it possible to build a new Docker image with a Dockerfile

Hello is it possible to build a docker image with nextstrain

Could you clarify what you’re trying to achieve? I’m not quite sure what you mean: do you want to use the nextstrain docker base image as a base image in your dockerfile, adding extra packages on top?

1 Like
# Use the Python base image
FROM python:3.9-slim AS nextstrain-view-base

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl

# Install Nextstrain CLI
RUN curl -fsSL --proto '=https' https://nextstrain.org/cli/installer/linux | bash ; printf '\n%s\n' 'eval "$("/root/.nextstrain/cli-standalone/nextstrain" init-shell bash)"' >> ~/.bashrc ; eval "$("/root/.nextstrain/cli-standalone/nextstrain" init-shell bash)"
#RUN printf '\n%s\n' 'eval "$("/root/.nextstrain/cli-standalone/nextstrain" init-shell bash)"' >> ~/.bashrc
#RUN eval "$("/root/.nextstrain/cli-standalone/nextstrain" init-shell bash)"

# Install Auspice dependencies
#RUN apt-get install -y \
#    build-essential \
#    npm

# Install Auspice globally
#RUN npm install --global auspice@2.23.0

# Set the working directory
WORKDIR /app

# Copy the necessary files to the working directory
COPY ./auspice /app

# Expose the port used by Auspice
EXPOSE 4000

# Set the entrypoint to run Auspice with --host=localhost
#ENTRYPOINT ["auspice"]

# Set the command to run Auspice
#CMD ["view", "--datasetDir", "/nextstrain/auspice"]
#CMD nextstrain view --host 0.0.0.0 --port 4000 /app
#CMD  nextstrain view --host 0.0.0.0 --port 4000 /app

CMD bash -c 'eval "$(nextstrain init-shell bash)" && nextstrain view --host 0.0.0.0 --port 4000 /app'

I have tested this dockerfile but it’s not working. I want just to make a docker container image for to view the nextstrain result

I see. This is the Dockerfile we use to build the nextstrain/docker-base image.

Why don’t you just use that? It’s hosted here: https://hub.docker.com/r/nextstrain/base/

You can also build on that image, as we do for example here: ncov-ingest/Dockerfile at master · nextstrain/ncov-ingest · GitHub

Thank you very much @corneliusroemer . Finally, I modified the nextstrain/base and it work.

Many thanks.

1 Like

nextstrain/docker-base: Docker image build for nextstrain/base (github.com)

1 Like

[@KhadimGueyeKGY also asked a very similar question via hello@, and I responded there, so I’m copying that response (with slight modifications) here for posterity.]

We document in our sharing guide a number of ways to share your results without running your own server. I’d encourage you to use one of those methods if possible, as there is much more overhead to running your own server or creating and maintaining your own Docker image.

It is possible to use our existing Docker image to run Auspice against your dataset JSON files, even without building a new image. Here’s an example of the docker run invocation to serve an auspice/ directory:

docker run \
    --rm \
    --interactive \
    --tty \
    --init \
    --env=HOST=0.0.0.0 \
    --env=PORT=4000 \
    --publish=4000:4000 \
    --volume="$PWD/auspice/:/nextstrain/auspice/data:ro" \
    --workdir=/nextstrain/auspice \
    nextstrain/base:latest \
        auspice view \
            --verbose \
            --datasetDir=data/ \
            --narrativeDir=data/

This does not require Nextstrain CLI to be installed on the system running it, but your Auspice dataset JSON files must be present.

If you really want to bundle the dataset JSON files into a new Docker image so nothing outside the image is required, that is also possible but more involved. There’s a lot that could be going wrong at several points with what you’ve tried so far, and debugging it from only the details you’ve shared would be difficult. Instead, here’s an example Dockerfile that does so:

FROM nextstrain/base:latest

ENV HOST=0.0.0.0
ENV PORT=4000
EXPOSE 4000

WORKDIR /nextstrain/auspice

COPY ./auspice ./data

CMD ["auspice", "view", "--verbose", "--datasetDir=data/", "--narrativeDir=data/"]

After building the new image from this, e.g. docker build -t name ., you’d run it with docker run --rm --interactive --tty --init --publish=4000:4000 name.

1 Like

Hi @corneliusroemer , Hi @trs ,

Thank you very much. I wanted just to build a docker image based on the nextstrian/docker-base.

Finaly, I used the the file of @trs .


FROM nextstrain/base:latest

ENV HOST=0.0.0.0
ENV PORT=4000
EXPOSE 4000


WORKDIR /nextstrain/aupice

COPY ./aupice_res ./data

CMD ["auspice", "build", "--verbose","--extend","data/config.json"]
CMD ["auspice", "view", "--verbose", "--datasetDir=data/aupice/", "--narrativeDir=data/aupice/"]

Many thanks for your help

1 Like