JetBrains SpaceCode Preview Help

Configure SpaceCode for Docker Compose Production Environment

Enable customization of your SpaceCode On-Premises instance

The Docker Compose installation of SpaceCode On-Premises comes with a predefined configuration that works out of the box. However, for SpaceCode On-Premises to work in a production environment, you should perform some additional configuration.

SpaceCode On-Premises configuration is a set of conf files stored in the SpaceCode application container. To configure SpaceCode On-Premises, you should copy the files to the host machine, modify them, and then point SpaceCode to the new file location.

  1. Open the {space_install_dir/config} directory (e.g., space-on-premises/config) and run:

    docker cp {space_container_id}:/home/space/circlet-server-onprem/config .

    The following configuration files will be copied to the {space_install_dir/config} directory on the host machine:

    • langservice.on-premises.conf

    • space.on-premises.conf

    • vcs.on-premises.properties

  2. Edit the configuration files according to your needs.

  3. Stop your SpaceCode instance:

    docker-compose -p space-on-premises down docker-compose -p space-on-premises rm -f

  4. Open the docker-compose.yml file located in the SpaceCode installation directory.

  5. Change the default location of the SpaceCode configuration files. To do this, edit the docker-compose.yml file:

    1. Comment out the config:{} line:

      ... # config:{} ...
    2. Change every reference to the docker volume configuration from config to ./config. Namely, from:

      ... volumes: - config:/home/init-config/config ... volumes: - config:/home/space/circlet-server-onprem/config ... volumes: - config:/home/space/git/vcs-hosting/config ... volumes: - config:/home/space/packages-server/config ... volumes: - config:/home/space/langservice-server/config ...

      to:

      ... volumes: - ./config:/home/init-config/config ... volumes: - ./config:/home/space/circlet-server-onprem/config ... volumes: - ./config:/home/space/git/vcs-hosting/config ... volumes: - ./config:/home/space/packages-server/config ... volumes: - ./config:/home/space/langservice-server/config ...
  6. Start SpaceCode On-Premises with the updated configuration:

    docker-compose -p space-on-premises up -d

Make your SpaceCode On-Premises instance network-accessible

By default, Docker Compose installation of SpaceCode On-Premises uses 127.0.0.1 and localhost as the base URLs. This configuration works well only in the proof-of-concept scenario when you run SpaceCode locally. If you want to run SpaceCode on a separate machine and make it network-accessible, you must use the nginx web server. It will work as a reverse proxy and redirect requests to SpaceCode.

Prerequisites:

  • The domain names for SpaceCode components are already registered and resolved to the IP address of the host machine. SpaceCode components include: SpaceCode application, VCS, and Packages server. In our example, we will use the following names: space.example.com, git.example.com, and packages.example.com.

  • The corresponding TLS certificates are installed on the host machine. You can obtain the certificates from a trusted certificate authority (e.g., Let's Encrypt).

  • The host machine has the nginx web server installed. You can find the installation instructions on the official website.

  1. On the host machine, create the space.conf NGINX configuration file in the /etc/nginx/conf.d directory. For example:

    server { client_max_body_size 0; server_name space.example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8084/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } listen 443 ssl; ssl_certificate /path_to_certs/space.example.com/fullchain.pem; ssl_certificate_key /path_to_certs/space.example.com/privkey.pem; } server { client_max_body_size 0; server_name git.example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } listen 443 ssl; ssl_certificate /path_to_certs/git.example.com/fullchain.pem; ssl_certificate_key /path_to_certs/git.example.com/privkey.pem; } server { client_max_body_size 0; server_name packages.example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8390/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } listen 443 ssl; ssl_certificate /path_to_certs/packages.example.com/fullchain.pem; ssl_certificate_key /path_to_certs/packages.example.com/privkey.pem; } server { client_max_body_size 0; server_name minio.example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:9000/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } listen 443 ssl; ssl_certificate /path_to_certs/packages.example.com/fullchain.pem; ssl_certificate_key /path_to_certs/packages.example.com/privkey.pem; } # configuring HTTP redirects server { if ($host = space.example.com) { return 301 https://$host$request_uri; } server_name space.example.com; listen 80; return 404; } server { if ($host = git.example.com) { return 301 https://$host$request_uri; } server_name git.example.com; listen 80; return 404; } server { if ($host = packages.example.com) { return 301 https://$host$request_uri; } server_name packages.example.com; listen 80; return 404; } server { if ($host = minio.example.com) { return 301 https://$host$request_uri; } server_name minio.example.com; listen 80; return 404; }

    In the example above, change:

    • All ssl_certificate and ssl_certificate_key paths to the real paths to your certificates.

    • All server_name values (space.example.com, git.example.com, and packages.example.com) to the real domain names.

  2. Save the changes and apply the configuration:

    sudo nginx -s reload
  3. Make your SpaceCode instance available for customization.

  4. Stop your SpaceCode instance if it is running.

  5. Open the SpaceCode installation directory.

  6. In the space.on-premises.conf file, update all url and altUrls parameters with new URL values. For example:

    circlet { frontend { url = "https://space.example.com" internalUrl = "http://space:9084" } packages { notifications { enabled = true } types { maven { url = "https://packages.example.com" } nuget { url = "https://packages.example.com" } npm { url = "https://packages.example.com" } container { url = "https://packages.example.com" } pypi { url = "https://packages.example.com" } composer { url = "https://packages.example.com" } dart { url = "https://packages.example.com" } files { url = "https://packages.example.com" } crates { url = "https://packages.example.com" } } } }
  7. In the packages.on-premises.conf file, update all url and internalUrl parameters with new URL values. For example:

    circlet { packages { url = "https://packages.example.com" internalUrl = "http://packages:9390" } space { url = "https://space.example.com" internalUrl = "http://space:9084" } storage { aws { publicUrl = "https://minio.example.com" } } }
  8. In the vcs.on-premises.properties file, update teh base.url and circlet.url.ext parameters with new URL values. For example:

    base.url=https://git.example.com circlet.url.int=http://space:9084 circlet.url.ext=https://space.example.com
  9. Start SpaceCode On-Premises with the updated configuration:

    docker-compose up -d

Enable mail server

The Docker Compose installation comes without a preconfigured mail server. The instructions below show how you can create a MailHog mail server and register it in SpaceCode.

  1. Stop your SpaceCode instance if it is running.

  2. Open the SpaceCode installation directory.

  3. In the docker-compose.yml file, add the mail server configuration:

    services: mailhog: image: mailhog/mailhog ports: - 1025:1025 # SMTP server port - 8025:8025 # UI port networks: - "frontend"
  4. Provide the mail server settings to SpaceCode. You can do this in two different ways: using the SpaceCode administration UI or using the SpaceCode configuration file.

    1. Start SpaceCode On-Premises with the updated configuration:

      docker-compose up -d
    2. Open your SpaceCode instance in the browser and specify mail settings as shown on this page.

    1. Make your SpaceCode instance available for customization.

    2. Open the space.on-premises.conf file and modify the mail configuration according to your requirements:

      mail { outgoing { enabled = true // protocol settings fromAddress = "space@space.example.com" host = "mailhog" port = 1025 protocol = "SMTP" // "SSL" and "TLS" are also supported login = "space" password = "space" messageQueuePrefix = "mailQueue" // handling properties aggregationDelaySecs = 900 rateLimitPerSecond = 3 } }
    3. Start SpaceCode On-Premises with the updated configuration:

      docker-compose up -d

(Case-specific) Enable manual downloads in SpaceCode Packages

If you use a custom object storage for your SpaceCode instance, you must configure its CORS policy to allow receiving GET requests from any origin:

Access-Control-Allow-Methods: GET Access-Control-Allow-Origin: *

Otherwise, users will not be able to manually download packages from the repository page in SpaceCode. Clicking the Download button will result in an error.

  1. Sign in to the AWS Management Console and open the Amazon S3 console.

  2. Open the S3 bucket used for SpaceCode Packages.

  3. Open the Permissions tab and add the following configuration to the CORS section:

    [ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ]
  4. Save the changes.

Last modified: 27 May 2024