Sample Docker Configuration
In this section we will explain how you can use Sidekick Node.js agent with a containerized application.
Sidekick agent can be used in containerized applications, without any extra modification in your application source code.
We highly recommend using your API key as an environment variable instead of hard-coded.
Below is a very common docker configuration for Nodejs applications.
First, create a directory. Install dependencies including the Sidekick agent. Bundle packages and bind ports. Finally, run the application with the start command you declared in the package.json file.
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "start"]
docker build . -t < NAME-YOUR-IMAGE >
As we mentioned before, we highly recommend using your API key as an environment variable.
To use Sidekick agent, you can either add variables to your Dockerfile or give them as a parameter to your run command or you can use a .env file as well.
Add this line to your Dockerfile before the npm start command
Run your container as below:
-e SIDEKICK_APIKEY=<YOUR-SIDEKICK-API-KEY> \
-e SIDEKICK_APPLICATION_NAME=<YOUR-APP-NAME> \
-e SIDEKICK_APPLICATION_STAGE=dev \
-e SIDEKICK_APPLICATION_VERSION=<YOUR-APP-VERSION> \
-e SIDEKICK_DEBUG_ENABLE=True \
-p 3000:3000 <NAME-YOUR-IMAGE>
Create a file with the .env extension and add the following to it using your own environment variables.
docker run ...