OnePub is Docker aware and designed to be run in a Docker container as well as on your host.
The are a few issues you need to be aware of when using a local or remote Docker container.
If you are going to use OnePub in your Docker container you will of course need to have Dart installed. You should also install OnePub by adding the following to your Dockerfile:
RUN dart pub global activate onepub
Dart must already have been installed into your Docker container in a prior step and be on the path.
If you are using the Docker container interactively (e.g.
docker exec -it xxx /bash) then you can log into OnePub from within the Docker container by running
If you Docker container runs without user interaction (the normal course of action) then you need to use the
onepub import/exportmethods or directly mount the Dart token store.
The simplest method is to use the onepub export/import commands.
From your desktop CLI run:
Note: you only need to run onepub login if you are not currently logged in.
onepub export --user <cicd user email>
onepub exportcommand will print your OnePub token.
Start an interactive docker session (e.g. docker exec -it xxxx /bash) and run:
onepub import --ask
When prompted for the ONEPUB_TOKEN, enter the token displayed when you ran the
You are now logged in to OnePub with the Docker session.
If your Docker home directory isn't persistent then you will have to re-do the import each time you restart your container.
If your docker container is running on your local PC then you can mount the OnePub and Dart configuration files directly into your docker container.
This will result in the Docker container running with your OnePub account.
For a container running on your local system, the docker
mount bindoption has the advantage that you don't have to log in to your Docker container separately (and each time you rebuild it). Simply log in to onepub on the host and the container will also be logged in.
docker exec \
--mount type=bind,source="/home/me/.config/dart/pub-tokens.json",destination="/home/root/.config/dart/pub-tokens.json" \
--mount type=bind,source="/home/me/.onepub/onepub.yaml",destination="/home/root/.onepub/onepub.yaml" \
If you are using VS Code the command :
Remote-Containers: Open Folder in Container...