Persistence: Full persistence for the entire development environment (code, configs, shell history, installed packages)
Networking Requirements
Full duplex communication between containers
Dev container should reach Go server at http://go-server:8080
Dev container should be able to send HTTP requests and receive responses for Playwright automation
Development Workflow
Primary usage: docker exec into the dev container
Use case: Headless browser automation and testing with Playwright
Building heuristics and testing websites programmatically
Deliverables
Please provide:
Complete Docker Compose YAML file
Dockerfiles for both containers
Sample Go HTTP server code (basic Chi/Gin example)
Complete zsh configuration file with the specified setup
Any additional configuration files needed
Clear file tree structure showing how all files should be organized
Setup and usage instructions
The goal is a robust development environment for web automation testing that persists across container restarts and provides a comfortable development experience with modern tooling.
Assistant
Here's a complete setup for the described Docker Compose development environment. This includes the Docker Compose file, Dockerfiles, sample Go HTTP server code, zsh configuration, and setup instructions.
# Use the official Go image.
FROM golang:1.24
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies.
RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container.
COPY . .
# Build the Go app
RUN go build -o main .
# Run the Go app
CMD ["./main"]
go-server/main.go
go
package main
import (
"github.com/go-chi/chi/v5"
"net/http"
)
func main() {
r := chi.NewRouter()
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/index.html")
})
http.ListenAndServe(":8080", r)
}
go-server/static/index.html
html
<!DOCTYPE html>
<html>
<head>
<title>Go HTTP Server</title>
</head>
<body>
<h1>Welcome to the Go HTTP Server!</h1>
</body>
</html>
dev-environment/Dockerfile
Dockerfile
# Use a base image with development tools
FROM ubuntu:22.04
# Install necessary packages
RUN apt-get update && apt-get install -y \
curl \
git \
zsh \
wget \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
nodejs \
npm \
python3-pip \
htop \
tree \
neovim \
&& apt-get clean
# Install Go
RUN wget https://golang.org/dl/go1.24.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go1.24.linux-amd64.tar.gz \
&& rm go1.24.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin
# Install Python packages
RUN pip3 install playwright
# Install Node.js packages
RUN npm install -g playwright
# Set up Zsh and Oh-My-Zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
# Install Powerlevel10k
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# Install plugins
RUN sed -i 's/plugins=(git)/plugins=(git docker docker-compose eza history-substring-search pip node python golang colored-man-pages fzf-tab zsh-autosuggestions fast-syntax-highlighting)/' /root/.zshrc
# Copy custom zsh configuration
COPY .zshrc /root/.zshrc
# Set Zsh as the default shell
RUN chsh -s $(which zsh) root
# Set the default command to start a shell
CMD ["zsh"]
# Development Environment Setup
## Setup Instructions
1. **Build and start the containers:**
```sh
docker-compose up --build
```
2. **Access the development environment:**
```sh
docker exec -it dev-environment zsh
```
3. **Verify Go server is accessible:**
```sh
curl http://go-server:8080
```
4. **Run Playwright tests:**
- Ensure you have your Playwright scripts in the `/home/dev` directory.
- Example command to run a Playwright test:
```sh
np playwright test
# or
python3 playwright_test.py
```
## Usage
- **Primary usage:** `docker exec -it dev-environment zsh` to enter the development container.
- **Headless browser automation and testing with Playwright.**
## Persistence
- The development environment, including code, configurations, and shell history, is fully persisted across container restarts due to volume mounts.
This setup provides a robust development environment for web automation testing with Playwright, featuring full persistence and modern tooling.