arp242 / goatcounter

Easy web analytics. No tracking of personal data.
https://www.goatcounter.com
Other
4.58k stars 190 forks source link

about docker #763

Open toyo2333 opened 3 months ago

toyo2333 commented 3 months ago

I understand that the author has previously expressed multiple times that Docker deployment will not be supported (because the current deployment method is already simple enough).

However, I still want to explain from a user's perspective why we hope to have Docker support: One GoatCounter is indeed very simple, but when you have 10-20 GoatCounters with different installation methods, data storage, update methods, and backup methods, it’s not so simple anymore.

At this point, the benefits of using Docker Compose become apparent: consistency in data storage and program management. Let me share my example:

1、All my projects are deployed using Docker and are placed in one directory:

./my_project/
├── docker-compose.yml
├── service1
│   └── container-data
├── service2
│   ├── container-config
│   └── container-data
├── service3
│   ├── container-data
│   └── container-extensions
├── service4
│   └── container-data
├── service5
│   ├── container-config
│   └── container-data
├── service6
│   ├── container-data
│   └── container-data2
├── service7
│   └── container-data
├── service8
│   └── container-data
└── service9
    ├── container-config
    └── container-data

I’m writing this mainly to explain the reasoning behind this request, nothing more.

maruel commented 2 months ago

Have you looked at using override in systemd? See https://askubuntu.com/a/659268/1657026. systemd supports both cgroups and namespace v2 to lock down the process' access.

jkseppan commented 4 days ago

It is not too hard to run Goatcounter in Docker - here's my Dockerfile, to be run with vendor/goatcounter populated with the source:

FROM golang:1.23 AS build
COPY vendor/goatcounter /go/src/goatcounter
WORKDIR /go/src/goatcounter
RUN CGO_ENABLED=0 \
    go build \
    -tags osusergo,netgo,sqlite_omit_load_extension \
    -ldflags="-X zgo.at/goatcounter.Version=2.5.0" \
    ./cmd/goatcounter

FROM scratch
COPY --from=build /go/src/goatcounter/goatcounter /goatcounter
ENTRYPOINT ["/goatcounter"]
CMD ["serve", "-automigrate", "-listen", ":8081", "-tls", "proxy", "-email-from", "nobody@localhost", "-db", "postgresql"]

Then use PG* variables to set the database parameters. There are complaints about not being able to use port 80, but the higher port still works.