I’ve tossed together a minimal docker container that makes playing with code and Chat-GPT a little more convenient. Provide a language to use, a task to solve, and a filename for the output script and a python script will submit the prompt and spit the output into a sub-folder for you (which is a mounted volume so the output scripts are on your local as well). From there it’s ready to be tweaked and run inside the container. Quickly add dependencies, throw it all away, start again. It’s a quick loop for testing and experimentation.
Download and install Docker or Docker Desktop.
Clone the project from https://github.com/chriscummings/CodePlayground-GPT
.env.example file to simply
Paste your OpenAI API key into the
.env file. (Sign up link here), then (API key link here)
Build the base image.
docker build -t playground-gpt .
Run the container with a mounted volume.
docker run -it -v $(pwd):/code playground-gpt /bin/bash
From here, you’re ready to play. Execute something along the lines of:
python playground-gpt.py <some-language> "<some-task>" <some-filename.ext>
Here I am submitting the following:
A new file,
xmas.js is created in the
I paste two images into the mounted volume of the
This time I’ve submitted:
python playground-gpt.py python3 "for a given directory list all child files that are images" x.py
After tweaking the directory path, it worked the first time. Often you have to clean it up a bit to get it to do exactly what you want.
This is a great workspace you can just throw away. Want to run Ruby and NPM? Just update and install anything you need.
apt-get install ruby npm
Dockerfiles as needed for a more permanent option.