Docker
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:
Dart must already have been installed into your Docker container in a prior step and be on the path.
Where possible start with a Docker container that includes Dart such as the official Dart Docker container.
onepub login
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 onepub login
.
If you Docker container runs without user interaction (the normal course of action) then you need to use the onepub import/export
methods or directly mount the Dart token store.
The same problem will exists in your CI/CD environment (which is usually running in a Docker container). See the CI/CD instructions for additional details pertinent to typical CI/CD environments.
Use export/import
The simplest method is to use the onepub export/import commands.
For additional details on authenticating onepub read the CI/CD guide
From your desktop CLI run:
Note: you only need to run onepub login if you are not currently logged in.
The onepub export
command will print your OnePub token.
Start an interactive docker session (e.g. docker exec -it xxxx /bash) and run:
When prompted for the ONEPUB_TOKEN, enter the token displayed when you ran the onepub export
command.
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.
Environment variable
The onepub import
command can also able to take the OnePub token from an environment variable. Refer to the import documentation for details.
Mount the Dart token store
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 bind
option 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.
If you are using VS Code the command :
Remote-Containers: Open Folder in Container...
then see the VS Code documentation for details on creating the mounts.
CI/CD
If your container is running in a CI/CD environment such as a github action then refer to the CI/CD documentation.
Last updated