aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-14 07:07:03 +0000
committerFuwn <[email protected]>2024-05-14 07:07:03 +0000
commitc343c9891771142c32d47724437db7b5db00d46b (patch)
tree06b3eaa7d284c1a57615ecaa435daafded0efbeb
parentci(github): gleam check workflow (diff)
downloadmayu-c343c9891771142c32d47724437db7b5db00d46b.tar.xz
mayu-c343c9891771142c32d47724437db7b5db00d46b.zip
feat(Docker): Docker supportv0.1.0
-rw-r--r--.gitignore1
-rw-r--r--Dockerfile25
-rw-r--r--README.md17
-rw-r--r--src/mayu.gleam4
4 files changed, 45 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index f70ab35..b6a9f72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ erl_crash.dump
# SQLite
*.sqlite3
+*.db
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..7c51b6f
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,25 @@
+FROM ghcr.io/gleam-lang/gleam:v1.1.0-erlang-alpine as builder
+
+WORKDIR /mayu/
+
+COPY src/ /mayu/src/
+COPY themes/ /mayu/themes/
+COPY gleam.toml /mayu/
+COPY manifest.toml /mayu/
+
+RUN apk add --no-cache build-base
+
+RUN gleam build \
+ && cd build/ \
+ && gleam export erlang-shipment
+
+FROM ghcr.io/gleam-lang/gleam:v1.1.0-erlang-alpine
+
+COPY --from=builder /mayu/build/erlang-shipment/ /mayu/erlang-shipment/
+COPY --from=builder /mayu/themes /mayu/themes/
+
+WORKDIR /mayu/
+
+ENTRYPOINT ["./erlang-shipment/entrypoint.sh"]
+
+CMD ["run"]
diff --git a/README.md b/README.md
index 4310f8c..950f407 100644
--- a/README.md
+++ b/README.md
@@ -2,14 +2,31 @@
> Moe-Counter Compatible Website Hit Counter
+Mayu is a drop-in replacement for [Moe-Counter](https://github.com/journey-ad/Moe-Counter) designed
+to be lightweight and easy to use.
+
+Mayu is written in [Gleam](https://gleam.run) and uses [SQLite](https://sqlite.org) as its database.
+
## Usage
+### Local
+
```bash
$ git clone [email protected]:Fuwn/mayu.git
$ cd mayu
$ gleam run
```
+### Docker
+
+```shell
+docker run --volume 'mayu:/mayu/data/' -p '80:3000' --rm fuwn/mayu:latest
+```
+
+### Database
+
+Mayu will use SQLite by default and will place the database file, `count.db`, within the `data/` directory of the project's root directory.
+
## Resource Attributions
- [A-SOUL_Official](https://space.bilibili.com/703007996)
diff --git a/src/mayu.gleam b/src/mayu.gleam
index 69e1474..95442e8 100644
--- a/src/mayu.gleam
+++ b/src/mayu.gleam
@@ -11,7 +11,7 @@ pub fn main() {
let _ = simplifile.create_directory("./data")
- use connection <- sqlight.with_connection("./data/mayu.sqlite3")
+ use connection <- sqlight.with_connection("./data/count.db")
database.setup(connection)
@@ -22,7 +22,7 @@ pub fn main() {
secret_key_base,
)
|> mist.new
- |> mist.port(8080)
+ |> mist.port(3000)
|> mist.start_http
process.sleep_forever()