Add docker image

This commit is contained in:
Mylloon 2023-05-16 01:41:19 +02:00
parent 81115dbc76
commit 3b2de6f973
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 57 additions and 19 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
_build/ _build/
/docker-compose.yml
/selenium-*.jar /selenium-*.jar
/gecko-*.tar.gz /gecko-*.tar.gz

24
Dockerfile Normal file
View file

@ -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"]

View file

@ -2,29 +2,42 @@
Send a tweet to prevent Twitter from closing your account. Send a tweet to prevent Twitter from closing your account.
## Requirements ## How to use?
```opam ## With Docker
$ opam switch list
# switch compiler description You can use this dockercompose template:
→ default ocaml-base-compiler.4.14.1 default
```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 ## Local
$ opam install cohttp-lwt-unix tls-lwt dotenv twostep
``` - 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 ## Name history
Derived from Elon's name :D. Thanks, Elon, for destroying Twitter. 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?