Docker
Integrate Onboardbase into Docker
Using Onboardbase with Docker.
Use cases:
- Protect secrets in your Docker image
- Easily define environment variables for your Docker image
- Easily create new Docker images for different environments
1. Dockerfile
FROM node:12.18.1
WORKDIR /project
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install
COPY . .
CMD [ "npm", "run", "start" ]
2. Building the image
sudo docker build --tag node-docker .
3. Running the image
docker run node-docker
With an environment variable:
docker run -e MY_SECRET="$STRIPE_SK" node-docker
Problem: the environment variable is hardcoded in the docker command.
4. Onboardbase run
We use the Onboardbase CLI to inject secrets at runtime:
onboardbase run -c 'sudo docker run -e MY_SECRET="$
STRIPE_SK" node-docker' -p "my project" -e "development"
The -p
option makes it easy to use the same image in different project and the -e
option allows devops engineers to quickly roll out apps in different environments.
5. Using Docker Compose
If you use Docker Compose, just put the environment variable in the compose file:
web:
environment:
- SECRET=${SECRET}
Docker Compose will automatically fetch the environment variables from the environment set by Onboardbase:
onboardbase run -c "docker compose up" -p "my project" -e "development"
Updated about 1 year ago