Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official Docker container at Docker hub #26

Closed
alexanderadam opened this issue Jan 15, 2020 · 23 comments 路 Fixed by #89
Closed

Official Docker container at Docker hub #26

alexanderadam opened this issue Jan 15, 2020 · 23 comments 路 Fixed by #89
Labels
self-hosting Anything self-hosted

Comments

@alexanderadam
Copy link

alexanderadam commented Jan 15, 2020

Hi folks,

thank you so much for your work. 馃檹
I just thought it would be nice to have an official 馃悑 Docker container for easier trying out plausible on a local machine or server.

See also nolt.io issue 56.

@ukutaht
Copy link
Contributor

ukutaht commented Jan 16, 2020

Thanks for opening the issue alex,

At the moment I'm working very actively on the product itself. I haven't made it easy to self-host because it's a lot of work and it would slow down development. Adding documentation for self-hosting and a Docker image is something I can see happening in the future but but I'm not going to address it immediately. Hope you understand.

@alexanderadam
Copy link
Author

Hi Uku,

awesome, thank you for your fast response!
I wasn't expecting something immediately at all, so no pressure on that.
I just thought it would probably a good idea in general, so no need to rush. 馃槈

@tjomk
Copy link

tjomk commented Mar 2, 2020

@alexanderadam It is fairly easy to run the app locally if you have node and Elixir installed. It's based on my setup (I prefer to run database via docker and Elixir/Node apps locally). Here's a rough step-by-step:

  1. Pull postgres docker container and run it: docker run -it --name plausible -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=plausible_dev. If you have different database settings, modify config/dev.exs and look for the block that starts with config :plausible, Plausible.Repo. It defines database connection.
  2. Install Elixir dependencies: mix deps.get. This should be run from the root of repository.
  3. Run database migrations: mix ecto.migrate
  4. Install frontend dependencies by going to the assets folder in the repo root and then running npm install.
  5. Start the app: mix phx.server

If everything went well, you should be able to access the app via http://localhost:8000.

Although keep in mind that as Uku mentioned, there's more to just starting the app locally. You'll need to dig a bit into the code to configure other aspects like e.g. email, landing page, trial, etc. But that should also get you going and set up for exploration :-)

@alexanderadam
Copy link
Author

Thank you for responding @tjomk,

I agree that this is fine for a development setup but a Docker container is obviously much easier for other environments. A properly tagged image allows easy rollbacks and updates. Also it wouldn't require to have all of the build dependencies locally available.

These are some reasons why other analytics alternatives can simply be tested/installed with a simple docker pull. They have all some official Docker containers available:

@weyert
Copy link

weyert commented Apr 11, 2020

Yeah, it's not easy to get this app running in Docker. Appears to ignore the environment variables during runtime. Only way to get it working is not to go for mix release and then run the release but get all the dependencies, build, at first start of the docker image.

@weyert
Copy link

weyert commented Apr 11, 2020

I have made a pull request #53 which will introduce a docker-compose script which runs the development build. It's a start...

@weyert
Copy link

weyert commented Apr 12, 2020

I am also made some changes here to make production build working: https://github.com/weyert/plausible/tree/production-release-docker

If anyone wanna try and help make it fully help that would be amazing. It's based on the Google Cloud dockerfile example

@weyert
Copy link

weyert commented Apr 15, 2020

Any feedback @ukutaht?

@tckb
Copy link
Contributor

tckb commented May 6, 2020

@alexanderadam / @ukutaht / @weyert As I have mentioned in #53 (comment) I have a fork with "docker" ready configuration.

Fork: https://gitlab.com/tckb-public/plausible
Docker Registry: registry.gitlab.com/tckb-public/plausible:master-e2a7df36

It still needs a read-me description. I will add it in coming days. I plan to maintain this, ofcourse for my own personal use. @ukutaht When you have time, please do check it, I can create a PR to push in my changes.

@alexanderadam
Copy link
Author

alexanderadam commented May 7, 2020

@tckb I like the changes you did. It looks well-thought-out! 馃憤
IMHO it would definitely be worth a PR.

Just one question: why did you switch away from the slim version?

@tckb
Copy link
Contributor

tckb commented May 7, 2020

@alexanderadam I've had https://gitlab.com/tckb-public/plausible/-/jobs/541156725#L2093 problem. Normally, this is usually due to missing packages in the base distro. This is why I avoid using the "slim" versions.

A reason why I moved away from alpine based images. This would be apparent when I add the image scanning stage (will do it in the coming days).

All in all, non-slim version is still at ~ 100Mb (the latest one is at 105.85 MiB).

@alexanderadam
Copy link
Author

alexanderadam commented May 7, 2020

@tckb
Copy link
Contributor

tckb commented May 7, 2020

@alexanderadam I haven't checked with just the installing ;) I did the changes together. I will check and add different images once I have all the other changes ready.

I would want to make few more changes before I officially open a PR, namely:

  • Choose between Bamboo.PostmarkAdapter and Bamboo.SMTPAdapter
  • Make Sentry Optional -It is good to have but, for a small personal hosting, this would require to have an account.
  • Make Google client Optional - It is good to have but, for a small personal hosting, this would require to have an account.

there are more. I will add it once I have the changes in place

@ukutaht
Copy link
Contributor

ukutaht commented May 12, 2020

@tckb These changes would be awesome and welcome. I'm super happy to review stuff and merge upstream. I will make an effort to be more active in this discussion as well to help as much as I can with the time I can dedicate to this.

Here are some more things to think about when it comes to self-hosting:

  • Billing/trial code locks people out after a 30-day trial if they don't have a subscription by then
  • Email templates need to be reviewed.
  • Some things are hardcoded, for example the script url is always https://plausible.io/js/plausible.js and the script fires to plausible.io/api/event. It's likely that there are more things that hard-coded but I can't think of any at the moment.
  • I am introducing a second database for the stats engine. Account and site info will be in postgres, but the stats themselves are going to Clickhouse. There's a Docker setup for that in the .travis.yml file. This is very much WIP at the moment.
  • Custom domain feature should be turned off for the self-hosted version. It will already be on a custom domain when you host it yourself. Not a big deal either, nothing bad happens if it ships with this feature but it just doesn't make sense to show it.

Some of these are not necessary for the first 'proof of concept' release but I just wrote a brain-dump of what I can think of at the moment.

@tckb
Copy link
Contributor

tckb commented May 12, 2020

@ukutaht glad to hear that you are on-board :)

I addressed some of the items you pointed out, but it will super helpful if you can help me in right direction, especially in pointing out the hardcoded items.

  • Billing/trial code locks people out after a 30-day trial if they don't have a subscription by then
    -- Resolved it by creating an "admin" user https://gitlab.com/tckb-public/plausible/-/issues/1
  • Email templates need to be reviewed.
  • Some things are hardcoded..

I tried to address some of the issues below
-- https://gitlab.com/tckb-public/plausible/-/issues/5
-- https://gitlab.com/tckb-public/plausible/-/issues/4
-- https://gitlab.com/tckb-public/plausible/-/issues/7

there are other items that I am working on here: https://gitlab.com/tckb-public/plausible/-/issues?scope=all&sort=created_date&state=all&utf8=%E2%9C%93

I added a readme of hosting documentation. .

@tckb
Copy link
Contributor

tckb commented May 15, 2020

@ukutaht @alexanderadam @weyert
I have created a draft PR for self-hosting #64

@Tragio
Copy link

Tragio commented May 21, 2020

Excited to see this going and hopefully out soon! I have one question, how the update is being handled? One way that I saw in another project is to have a docker.sh script with three functions, install, update-self to download the latest .sh from git, and update to bring the new docker-compose.yml from git and execute it. Don't know if is suitable in this case but can be helpful 馃槃

@ukutaht
Copy link
Contributor

ukutaht commented May 21, 2020

I don't have much experience with this so I'm lookg to @tckb and others for guidance.

We can potentially run any needed migrations when Docker boots, so an upgrade would just be pulling a new Docker image and running it. The new version would migrate the data volumes to the necessary state and boot the server. Not sure if that could work?

@tckb
Copy link
Contributor

tckb commented May 21, 2020

@Kulcanhez as I see, there's no "Self-update" (i.e., update to next stable version etc) process in place and I am not sure if this even make sense. The idea is that the latest version will be pushed to docker hub and you can use the sample docker-compose.yml to spin up your instance based on your environment.

a migration of db is already pre-cooked into the docker image, as a example in the sample docker-compose, the db migration is executed on first run. https://github.com/tckb/plausible/blob/master/docker-compose.yml#L37
More details are here: https://github.com/tckb/plausible/blob/master/HOSTING.md#database-migration

Hope that helps 馃憤

@Tragio
Copy link

Tragio commented May 28, 2020

@tckb @ukutaht thank you for your amazing work 鉂わ笍 I wonder what needs testing so we can use it in production.

@ukutaht
Copy link
Contributor

ukutaht commented May 29, 2020

Yeah, massive thanks to @tckb for the work done so far. We're quite close to having it ready for testing.

I'm working on the codebase to decouple it from my current hosting setup so it works with the Docker setup. Today I'm integrating Oban for background job processing so the scheduling is done by the app itself. I also need to integrate MaxMind's GeoIP database so we're not relying on an external CDN to get visitor location information.

AFAIK, @tckb is looking at migrations with Clickhouse. Currently, I'm managing the schema manually which is not ideal for a self-hosted solution.

There's also work to integrate it with my Travis setup and push images to DockerHub.

My goal is to have a public alpha ready for people to test by the end of next week. Would you be interested in running and testing it?

@Tragio
Copy link

Tragio commented May 29, 2020

Yeah, massive thanks to @tckb for the work done so far. We're quite close to having it ready for testing.

I'm working on the codebase to decouple it from my current hosting setup so it works with the Docker setup. Today I'm integrating Oban for background job processing so the scheduling is done by the app itself. I also need to integrate MaxMind's GeoIP database so we're not relying on an external CDN to get visitor location information.

AFAIK, @tckb is looking at migrations with Clickhouse. Currently, I'm managing the schema manually which is not ideal for a self-hosted solution.

There's also work to integrate it with my Travis setup and push images to DockerHub.

My goal is to have a public alpha ready for people to test by the end of next week. Would you be interested in running and testing it?

@ukutaht absolutely, keep me updated!! 馃槂 Yesterday came to my mind that it would be nice for the self-hosted solutions to have a little reminder in the dashboard saying something like "If you love this project consider supporting it." so people don't forget it. 馃構

@tckb
Copy link
Contributor

tckb commented May 29, 2020

@Kulcanhez since clickhouse library isn't supported by ecto, there's no ecto migration but, I have added the necessary steps for migration in existing migration steps.

the database migration takes care of both clickhouse and postgres. There should be a possibility of using clickhouse_ecto in the next releases.

Once Oban is added, I will add this to the migrations as well. @ukutaht would it posssible to add me to the PR ? I would want to create some more changes on my end

@metmarkosaric metmarkosaric added the self-hosting Anything self-hosted label Jun 19, 2020
@tckb tckb mentioned this issue Jun 19, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-hosting Anything self-hosted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants