Skip to content

Commit

Permalink
chore: get this running on server again
Browse files Browse the repository at this point in the history
  • Loading branch information
pikdum committed Sep 14, 2024
1 parent 055e7a0 commit 7d22673
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
11 changes: 6 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
_build
db
deps
maps
priv
.git/
_build/
db/
deps/
maps/
priv/
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM elixir:1.17 AS build
FROM docker.io/library/elixir:1.17 AS build
ENV MIX_ENV=prod
COPY --from=rust:latest /usr/local/cargo/bin/* /usr/local/bin/
RUN rustup default stable
COPY --from=docker.io/library/rust:slim /usr/local/cargo /usr/local/cargo
COPY --from=docker.io/library/rust:slim /usr/local/rustup /usr/local/rustup
ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=/usr/local/cargo/bin:$PATH
WORKDIR /app
RUN mix local.hex --force && mix local.rebar --force
COPY mix.exs mix.lock ./
Expand All @@ -10,7 +13,7 @@ COPY . .
RUN mix compile
RUN mix release

FROM elixir:1.17
FROM docker.io/library/elixir:1.17
WORKDIR /app
COPY --from=build /app/_build/prod/rel/thistle_tea ./
EXPOSE 3724
Expand Down
8 changes: 7 additions & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ SCRIPT_DIR="$(dirname "$(realpath "$0")")"
SOURCE_DIR="$(realpath "$SCRIPT_DIR/../")"

# exclude _build and .git
rsync -avz --exclude '.*' --exclude 'priv' --exclude '_build' --exclude 'deps' "$SOURCE_DIR/" $SERVER:~/thistle_tea/
rsync -avz \
--exclude '.git' \
--exclude '.lexical' \
--exclude 'priv' \
--exclude '_build' \
--exclude 'deps' \
"$SOURCE_DIR/" $SERVER:~/thistle_tea/

ssh $SERVER "/home/opc/thistle_tea/scripts/run.sh"
10 changes: 3 additions & 7 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env bash
set -euxo pipefail

export PATH="/home/opc/.local/share/mise/shims:$PATH"
export MIX_ENV=prod
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
SOURCE_DIR="$(realpath "$SCRIPT_DIR/../")"

cd "$SOURCE_DIR"
_build/prod/rel/thistle_tea/bin/thistle_tea stop || true
rm -rf _build
mix deps.get
mix release
_build/prod/rel/thistle_tea/bin/thistle_tea daemon
sudo podman build . -t thistle_tea
sudo podman auto-update
sudo podman system prune -af
14 changes: 14 additions & 0 deletions scripts/thistle_tea.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# /etc/containers/systemd/thistle_tea.container
[Container]
Image=localhost/thistle_tea:latest
PublishPort=3724:3724
PublishPort=8085:8085
Volume=/home/opc/thistle_tea/db:/app/db:Z
Volume=/home/opc/thistle_tea/maps:/app/maps:Z
AutoUpdate=local

[Service]
Restart=always

[Install]
WantedBy=default.target

0 comments on commit 7d22673

Please sign in to comment.