Skip to content

Go Web Server

A minimal web server written in Go using the standard library. Demonstrates deploying a compiled language application on AppMecca with multi-stage Docker builds for small, efficient images.

Overview

Repository git@gitlab.com:appmecca-sample-apps/go-web-server.git
Tech Stack Go 1.22 / stdlib net/http
Services web (port 8080)
Database None
Cache None
URL Pattern https://go-web-server-web.{env}.appmecca.net

What This App Demonstrates

  • Deploying a compiled Go binary on AppMecca
  • Multi-stage Docker builds (compile in one stage, run in another)
  • Minimal container images (around 15 MB vs 300+ MB)
  • Using Go's standard library for HTTP serving

appmecca.yaml

containers:
  - name: web
    dockerfile: Dockerfile
    context: .

deploy:
  - name: web
    container: web
    port: 8080
    health_check:
      path: /health

The configuration is identical in structure to any other single-container app. The only difference is the port -- Go's net/http is configured to listen on 8080 by convention.

Step-by-Step Deployment

1. Register the app

mecca register git@gitlab.com:appmecca-sample-apps/go-web-server.git -e dev

2. Build the container

mecca build trigger -e dev -g git@gitlab.com:appmecca-sample-apps/go-web-server.git
Expected output
Build started: build-xxxxxxxx
Cloning repository...
Building container: web
Pushing image to the private registry: go-web-server/web
Build complete. Duration: 32s

Go builds tend to be fast because the compiler produces a single static binary with no runtime dependencies.

3. Deploy

mecca app deploy -e dev go-web-server
Expected output
Deploying go-web-server to dev...
Deployment queued: deploy-xxxxxxxx
Waiting for agents...
Container started: go-web-server-web
Health check passed: /health -> 200 OK
Deployment complete.

Services:
  web: https://go-web-server-web.dev.appmecca.net

4. Verify

mecca queue status takes the action ID printed when you deployed. To look up the app itself — including the exact URL for your group — use mecca app show:

mecca app show go-web-server -e dev

Test the endpoint:

curl https://go-web-server-web.dev.appmecca.net/health
{"status": "healthy"}

Key Concepts

Multi-stage Docker builds

Go applications benefit significantly from multi-stage builds. The first stage uses the full Go toolchain to compile the binary. The second stage copies only the compiled binary into a minimal base image.

# Stage 1: Compile
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY main.go .
RUN go build -o server main.go

# Stage 2: Run
FROM alpine:3.19
COPY --from=builder /app/server /server
EXPOSE 8080
CMD ["/server"]

Image size comparison

Stage Image size
golang:1.22-alpine (build stage) ~300 MB
Final image (Alpine + binary) ~15 MB

The final image contains only Alpine Linux and your compiled binary. No Go toolchain, no source code, no build artifacts.

Static binaries

Go compiles to a static binary by default, which means the resulting executable has no external dependencies. This lets you use extremely small base images like alpine or even scratch (an empty image).

Port conventions

Go applications commonly listen on port 8080, but you can use any port. The port value in appmecca.yaml must match whatever your application listens on inside the container. AppMecca handles the external routing -- users always access your app over HTTPS on port 443.

Any language, same workflow

AppMecca does not care what language your application is written in. As long as your container listens on the declared port and responds to health checks, the deployment workflow is identical for Go, Python, Node.js, Rust, Java, or anything else.

What's Next?