Skip to content

A minimal Docker image to run Perforce without the hassle

Notifications You must be signed in to change notification settings

derkork/perforce-mini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perforce-mini

A minimal Docker image to run Perforce without the hassle. This image will automatically configure the Perforce server, so it will run without any manual steps required. I have very little experience with Perforce and while this image works for me it may not be suitable for a professional environment. I have set it up to be simple and relatively secure, but please keep in mind that this is a hobby project. If you find any issues or have any suggestions please open an issue or a pull request.

Running with docker-compose

To run this with docker-compose you can use a file like this:

version: '3'
services:
  perforce:
    # The image to use.
    image: derkork/perforce-mini:latest
    restart: unless-stopped
    volumes:
      # This is where the configuration is stored. Create an empty folder and mount this.
      # When the container starts for the first time it will detect that no configuration
      # exists and will automatically configure Perforce. The configuration will then be stored
      # in the mounted folder.
      - ./p4dctl.conf.d:/etc/perforce/p4dctl.conf.d
      # Perforce's data directory. This is where all the data is stored. Again, create an empty
      # folder and mount it here. The container will automatically configure Perforce to use this
      # folder.
      - ./perforce-data:/perforce-data
    environment:
      # === REQUIRED SETTINGS ===
      # The UID and GID of the user running the perforce server. While the container runs as
      # root, the perforce server itself will run as a non-priveleged user. This is the UID and
      # GID of that user. Make it match a user of the host system so that the files created by
      # the perforce server will be owned by that user. This is important so you can backup
      # the data directory on the host system. Both values are required.
      - PERFORCE_UID=1000
      - PERFORCE_GID=1000

      # === OPTIONAL SETTINGS ===
      # The following settings have reasonable defaults, but you can change them if you need to.
      
      # The port on which the Perforce server will listen. Optional, if unset the value will be `1666`.
      - P4PORT=1666
      # The root directory of the Perforce server. Make sure it matches the volume mount above.
      # Optional, if unset the value will be `/perforce-data`.
      - P4ROOT=/perforce-root
      # The server ID. You can change this to whatever you want. Optional, if unset the value will
      # be `perforce`.
      - SERVER_ID=my-perforce-server
      # This is the master user that will be created. The password for this user will be
      # randomly generated and printed to the console when the container starts. You can 
      # later change this password using the `p4 passwd` command. Optional, if unset the value
      # will be `perforce-master`.
      - MASTER_USER=perforce-root
      # Additional arguments for the first time setup of perforce. These values are allowed
      # `--unicode` - enables unicode support
      # `--case 0` - enables case sensitivity 
      # `--case 1` - disables case sensitivity	
      # Optional, if unset the value will be `--unicode`.
      - PERFORCE_SETUP_OPTS=--unicode --case 0
      # Additional arguments for the perforce server. Optional, if unset the value will be
      # empty. See the [Perforce documentation](https://www.perforce.com/manuals/p4sag/Content/P4SAG/appendix.p4d.html)
      # for a list of available options.
      - PERFORCE_SERVER_OPTS=

    ports:
      # The port to expose. Make sure it matches the P4PORT environment variable.
      - 1666:1666

Master user password

Since I didn't want to have an insecure default password, this container will create a random password for the master user. The password will be printed to the console when the container starts. You can change this password later using a perforce client.

perforce-perforce-1  | Generating random master password...
perforce-perforce-1  | Master password: yhkQP3hYrg5yns7d2EepV1fm9wAcEIGu

This password will only be printed once, so make sure to copy it somewhere safe. In case you lost the password, you can always delete the container and the contents of the p4dctl.conf.d folder and start over.

SSL Certificates

On first start the Perforce initialization script will automatically generate an SSL certificate for the Perforce server. The certificate will be valid for 2 years. If the certificate expires, simply delete the certificate.txt and privatekey.txt files from root/ssl folder in the Perforce data directory and restart the container. The container will automatically generate a new certificate.

Acknowledgements

  • Thanks to Ari for making this tutorial which I used as a starting point for this image.
  • Thanks to Polymoon Games for making this tutorial on how to refresh the SSL certificates for Perforce, which I used as a starting point to implement automatic certificate renewal.

About

A minimal Docker image to run Perforce without the hassle

Resources

Stars

Watchers

Forks

Releases

No releases published