diff --git a/build/Dockerfile b/build/Dockerfile index 0608953..60fa0ac 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -35,4 +35,4 @@ VOLUME /data ENV DATABASE_PATH=/data/zdravko.db ENV TEMPORAL_DATABASE_PATH=/data/temporal.db -ENTRYPOINT ["/zdravko"] +ENTRYPOINT ["/bin/zdravko"] diff --git a/deploy/Dockerfile b/deploy/Dockerfile deleted file mode 100644 index d6da698..0000000 --- a/deploy/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# syntax=docker/dockerfile:1 -ARG ZDRAVKO_VERSION=main - -FROM ghcr.io/mentos1386/zdravko:${ZDRAVKO_VERSION} -RUN apt-get update -y \ - && apt-get install -y ca-certificates fuse3 sqlite3 - -COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs - -COPY deploy/litefs.yaml /etc/litefs.yml -COPY deploy/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/deploy/entrypoint.sh b/deploy/entrypoint.sh deleted file mode 100755 index 7fc58a2..0000000 --- a/deploy/entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -PROCESS=${FLY_PROCESS_GROUP} - -if [ "$PROCESS" = "server" ]; then - echo "Starting server process" - exec litefs mount -- $@ -elif [ "$PROCESS" = "worker" ]; then - echo "Starting worker process" - exec $@ -else - echo "Unknown process" - exit 1 -fi diff --git a/deploy/fly.toml b/deploy/fly.toml index 24b6617..a034f57 100644 --- a/deploy/fly.toml +++ b/deploy/fly.toml @@ -1,39 +1,52 @@ +# fly.toml app configuration file generated for zdravko on 2024-02-17T21:20:17+01:00 +# # See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# app = 'zdravko' primary_region = 'waw' [build] - dockerfile = "Dockerfile" - context = "deploy" + image = 'ghcr.io/mentos1386/zdravko:main' [env] - ROOT_URL = 'https://zdravko.mnts.dev' - - OAUTH2_ENDPOINT_TOKEN_URL = 'https://github.com/login/oauth/access_token' OAUTH2_ENDPOINT_AUTH_URL = 'https://github.com/login/oauth/authorize' + OAUTH2_ENDPOINT_TOKEN_URL = 'https://github.com/login/oauth/access_token' OAUTH2_ENDPOINT_USER_INFO_URL = 'https://api.github.com/user' - - TEMPORAL_UI_HOST = 'server.process.zdravko.internal:8223' + ROOT_URL = 'https://zdravko.mnts.dev' TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233' [processes] - server = "/zdravko --temporal=true --server=true --worker=false" - worker = "/zdravko --temporal=false --server=false --worker=true" + server = '--temporal=true --server=true --worker=false' + worker = '--temporal=false --server=false --worker=true' [[mounts]] - source = "zdravko_data" - destination = "/var/lib/litefs" - processes = ["server"] + source = 'data' + destination = '/data' + processes = ['server'] [http_service] - processes = ["server"] internal_port = 8080 force_https = true auto_stop_machines = true auto_start_machines = true + min_machines_running = 0 + processes = ['server'] + +[[services]] + protocol = 'tcp' + internal_port = 7233 + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['server'] + +[[services.ports]] + port = 7233 + handlers = ['tls'] [[vm]] cpu_kind = 'shared' cpus = 1 memory_mb = 256 + processes = ['server', 'worker'] diff --git a/deploy/litefs.yaml b/deploy/litefs.yaml deleted file mode 100644 index f5f57f4..0000000 --- a/deploy/litefs.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# This directory is where your application will access the database. -fuse: - dir: "/data" - -# This directory is where LiteFS will store internal data. -# You must place this directory on a persistent volume. -data: - dir: "/var/lib/litefs" - -lease: - type: "consul" - - # Specifies if this node can become primary. The expression below evaluates - # to true on nodes that are run in the primary region. Nodes in other regions - # act as non-candidate, read-only replicas. - candidate: ${FLY_REGION == PRIMARY_REGION} - - # If true, then the node will automatically become primary after it has - # connected with the cluster and sync'd up. This makes it easier to run - # migrations on start up. - promote: true - - # The API URL that other nodes will use to connect to this node. - advertise-url: "http://${FLY_ALLOC_ID}.vm.${FLY_APP_NAME}.internal:20202" - - consul: - # The URL of the Consul cluster. - url: "${FLY_CONSUL_URL}" - - # A unique key shared by all nodes in the LiteFS cluster. - # Change this if you are running multiple clusters in a single app! - key: "${FLY_APP_NAME}/primary" diff --git a/internal/activities/healthcheck.go b/internal/activities/healthcheck.go index 6b1b9ad..e97c119 100644 --- a/internal/activities/healthcheck.go +++ b/internal/activities/healthcheck.go @@ -50,28 +50,7 @@ type HealtcheckHttpAddToHistoryParam struct { type HealthcheckHttpAddToHistoryResult struct { } -func HealthcheckHttpWriteResult(ctx context.Context, param HealtcheckHttpParam) (*HealthcheckHttpResult, error) { - if param.Method == "" { - param.Method = "GET" - } +func HealthcheckHttpAddToHistory(ctx context.Context, param HealtcheckHttpAddToHistoryParam) (*HealthcheckHttpAddToHistoryResult, error) { - var ( - response *http.Response - err error - ) - - switch param.Method { - case "GET": - response, err = http.Get(param.Url) - case "POST": - response, err = http.Post(param.Url, "application/json", nil) - } - - if err != nil { - return nil, err - } - - log.Printf("HealthcheckHttpActivityDefinition produced statuscode %d for url %s", response.StatusCode, param.Url) - - return &HealthcheckHttpResult{StatusCode: response.StatusCode}, nil + return &HealthcheckHttpAddToHistoryResult{}, nil } diff --git a/justfile b/justfile index 65a4cff..cfb15b6 100644 --- a/justfile +++ b/justfile @@ -20,7 +20,7 @@ run-zdravko: # Deploy the application to fly.io deploy: - fly deploy -c deploy/fly.toml + fly deploy --ha=false -c deploy/fly.toml # Start devbox shell shell: