Skip to content

Instantly share code, notes, and snippets.

@jaysson
Created August 18, 2024 14:31
Show Gist options
  • Save jaysson/4cfe951ff1a272efe0e512c92ffa7222 to your computer and use it in GitHub Desktop.
Save jaysson/4cfe951ff1a272efe0e512c92ffa7222 to your computer and use it in GitHub Desktop.
The devcontainer setup for a Warpdocs golang SaaS
{
"name": "Warpdocs Dev Container",
"dockerComposeFile": "./docker-compose.yml",
"workspaceFolder": "/workspace",
"service": "app",
"forwardPorts": [8000],
"customizations": {
"vscode": {
"extensions": [
"golang.Go",
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"pbkit.vscode-pbkit"
]
}
}
}
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
ports:
- "8000:8000"
volumes:
- ..:/workspace:cached
depends_on:
- db
- mailhog
- redis
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: warpdocs
mailhog:
image: mailhog/mailhog
restart: unless-stopped
ports:
- "1025:1025"
- "8025:8025"
redis:
image: redis:latest
restart: always
ports:
- "6379:6379"
volumes:
- redis-data:/data
volumes:
postgres-data:
redis-data:
FROM mcr.microsoft.com/devcontainers/base:ubuntu
# Install Go
ARG TARGETARCH
ARG GO_VERSION=1.23.0
RUN curl -fsSL https://golang.org/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xzf -
RUN BIN="/usr/local/bin" && \
VERSION="1.37.0" && \
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
# Set the working directory
USER vscode
WORKDIR /workspace
# Set up Go path
ENV GOPATH=/home/vscode/go
ENV PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
&& go install github.com/kollalabs/protoc-gen-openapi@latest
CMD ["sleep", "infinity"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment