Skip to content

Instantly share code, notes, and snippets.

@sttk
Last active November 7, 2025 13:27
Show Gist options
  • Select an option

  • Save sttk/2411bb92df89a83b1c5ae28ef8618850 to your computer and use it in GitHub Desktop.

Select an option

Save sttk/2411bb92df89a83b1c5ae28ef8618850 to your computer and use it in GitHub Desktop.

Copilot CLI on docker container

1. Build a docker image for copilot-cli

1.1. Install copilot-cli

FROM node:24

RUN npm install -g @github/copilot

USER node

WORKDIR /home/node
docker buildx build -t docker-copilot-setup .
docker run --name setup -it docker-copilot-setup bash

1.2. Login github for copilot-cli

See: https://github.com/github/copilot-cli

Open the URL: https://github.com/settings/personal-access-tokens/new or transfer pages as follows:

  • Settings > Developer settings > Personal access tokens > Fine-grained tokens

Create a personal access token with permissions: Copilot Requests

node@containerid:/~$ export GITHUB_TOKEN=(personal access token)
node@containerid:/~$ copilot
Confirm folder trust
    /home/node
    (Choose: 2. Yes, and remember this folder for future sessions)

> /login
What account do you want to log into?
    (Choose: 1. GitHub.com)

    (Open the URL: https://github.com/login/device)
    (Authorize github by entering one-time code)

Press any key to copy to clipboard and open browser...
    (Press any key, then a message suggesting a login failure appears briefly, but login succeeds after a while.)

Would you like to store the token in the plain text config file instead?
    (Choose: 1. Yes, I accept that risk.)

(Exit copilot, but don't exit docker)

1.3. Save the current container state as a Docker image

On a different terminal, create a Docker image from the current container's state.

docker commit setup docker-copilot:latest

After exiting the Docker container, delete the container used for setup.

docker rm setup

2. Create Rust development environment

2.1. Install Rust

FROM docker-copilot

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

USER node

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH="/home/node/.cargo/bin:$PATH"

RUN cargo install cargo-llvm-cov && \
    cargo install cargo-msrv --locked

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_rust -t docker-copilot-rust .

2.2. Run docker-copilot-rust with local directory synchronization

docker run --name copilot-rust -v ./:/home/node/workspace -it docker-copilot-rust bash

3. Create Golang development environment

3.1. Install Golang

FROM docker-copilot

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

RUN curl -OL https://go.dev/dl/go1.25.1.linux-amd64.tar.gz && \
    tar -C /usr/local -xzf go1.25.1.linux-amd64.tar.gz

USER node

ENV PATH="/usr/local/go/bin:$PATH"

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_go -t docker-copilot-go .

3.2. Run docker-copilot-go with local directory synchronization

docker run --name copilot-go -v ./:/home/node/workspace -it docker-copilot-go bash

4. Create Java development environmet

4.1. Install Java

FROM docker-copilot

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

USER node

WORKDIR /home/node

RUN curl -OL https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_linux-x64_bin.tar.gz && \
    tar -xzf graalvm-jdk-25_linux-x64_bin.tar.gz

ENV PATH=/home/node/graalvm-jdk-25+37.1/bin:$PATH

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_java -t docker-copilot-java .

4.2. Run docker-copilot-java with local directory synchronization

docker run --name copilot-java -v ./:/home/node/workspace -it docker-copilot-java bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment