From 3b2de6f973044505397e20fa3c0335331e059886 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 16 May 2023 01:41:19 +0200 Subject: [PATCH] Add docker image --- .gitignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ README.md | 51 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index d59a07d..6c5aa7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ _build/ +/docker-compose.yml /selenium-*.jar /gecko-*.tar.gz diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7f0b2b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# syntax=docker/dockerfile:1 + +FROM ocaml/opam:alpine-3.17-ocaml-4.14 AS builder +WORKDIR /usr/src/pusk +COPY . . + +USER root +RUN apk add gmp-dev pcre-dev && \ + chown -R opam:opam . + +USER opam +RUN opam install -y dune cohttp-lwt-unix dotenv twostep lwt_ssl && \ + eval $(opam env) && \ + dune install + +FROM alpine:3.17 + +WORKDIR /app + +RUN apk add dumb-init firefox libc6-compat pcre-dev + +COPY --from=builder /usr/src/pusk/_build/install/default/bin/pusk /app/pusk + +CMD ["dumb-init", "./pusk"] diff --git a/README.md b/README.md index 466c905..315ddd4 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,42 @@ Send a tweet to prevent Twitter from closing your account. -## Requirements +## How to use? -```opam -$ opam switch list -# switch compiler description -→ default ocaml-base-compiler.4.14.1 default +## With Docker + +You can use this dockercompose template: + +```yaml +version: "3.9" + +services: + pusk: + build: . + container_name: Pusk + environment: + - TWITTER_USERNAME=yourusername # not your mail + - TWITTER_PASSWORD=yourpassword + - TWITTER_TOTP=yourseed # optional if you don't have 2fa + - PUSK_DEBUG=false # optional + restart: unless-stopped ``` -```sh -$ opam install cohttp-lwt-unix tls-lwt dotenv twostep -``` +## Local + +- You will need these dependencies: + + ```sh + $ opam install cohttp-lwt-unix tls-lwt dotenv twostep lwt_ssl + ``` + +- Populate your credentials in [config/.env](./config/.env) +- Then you can run the bot with: + + ```sh + $ dune exec pusk + ``` ## Name history Derived from Elon's name :D. Thanks, Elon, for destroying Twitter. - -## TODO list - -- [x] Download a driver -- [x] Run a driver in background during the life of the app -- [x] [Figuring out how to use drivers](https://w3c.github.io/webdriver/#endpoints) -- [x] Login to Twitter.com -- [x] Check if latest tweet of user is more or less old than 30 days -- [x] Then tweet if needed something like "Don't delete my account please" -- [x] Close everything properly -- [ ] Maybe create a docker image for easy deployment?