Skip to content

Instantly share code, notes, and snippets.

@akanchhaS
Last active April 12, 2023 16:18
Show Gist options
  • Save akanchhaS/baffec93085249167c538f776d9cea58 to your computer and use it in GitHub Desktop.
Save akanchhaS/baffec93085249167c538f776d9cea58 to your computer and use it in GitHub Desktop.
TeamCity Docker compose

Setting up team city server and agent on your local machine with Snyk security plugin

TeamCity is one of the popular Build Automation tools and requires running of the Server and agent.

There are different ways of installing it which you can read more about here. This document specifically lists out the steps of running it locally.

Note: This doc covers basic steps to get the Teamcity and snyk security plugin set up and running.

Prerequisites

Docker to be installed and present on your machine.

Steps:

  1. Create mapping directories for the teamcity/data, teamcity/logs and teamcity/conf cd to the directory where you want to set your teamcity configs and then run the following commands
mkdir teamcity/data
mkdir teamcity/logs
mkdir teamcity/conf
  1. Copy the above docker-compose.yml in the same directory
  2. Run docker-compose build
  3. Run docker-compose up

The above command will spin up the teamcity agent and teamcity server and now you can access your Teamcity set up by accessing the http://localhost:8111 on your browser.

Note: To add Snyk security plugin in Teamcity, navigate to Administration > Server Administration - Plugins. Next Browser plugins and search Snyk security - then hit Get 😄

image

image

image

Setting up Snyk security as one of your Build Steps

Note: the following steps would come in once you have logged in to your teamcity server, set up a project (Admin - Create project) and are setting up Snyk as one of the build steps.

  1. Go to your Buids - Edit configuration - Build Steps
  2. Select Parameters from the left pane and Select Add New Parameter
  3. In the dialog box provide the vairable name as SNYK_TOKEN and as value provide the API token and hit Save
  4. Now that your parameter is set up, come to the Build Steps and click the Add Build Step Button
  5. Select Snyk Security - set up the fields as per your requirements; For the Snyk API Token field click on the small icon next to the textbox for the drop down to appear and select the SNYK_TOKEN
  6. Hit Save
  7. You are now good to run your Build!

Note: You want to always add the Snyk security step after the dependencies have been installed for Snyk to test the open source dependencies. And hence, under execute step the value would be - if all previous steps finished successfully.

image

image

image

image

version: '2.1'
services:
server:
image: "jetbrains/teamcity-server:latest"
ports:
- "8111:8111"
volumes:
- /<your path>/teamcity/data:/data/teamcity_server/datadir
- /<your path>/teamcity/logs:/opt/teamcity/logs
team-city-agent-1:
image: "jetbrains/teamcity-agent:latest"
privileged: true
volumes:
- /<your path>/teamcity/conf:/data/teamcity_agent/conf
environment:
- SERVER_URL=http://server:8111
- DOCKER_IN_DOCKER=start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment