Skip to content

Commit 055e80e

Browse files
committed
chore: new deploy action and bump Dockerfile
1 parent aac3166 commit 055e80e

7 files changed

Lines changed: 78 additions & 29 deletions

File tree

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Publish
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
tags:
8+
- "v*"
9+
10+
jobs:
11+
build-and-push:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.repository_owner }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ghcr.io/${{ github.repository_owner }}/live-react-examples
35+
tags: |
36+
type=semver,pattern={{version}}
37+
type=semver,pattern={{major}}.{{minor}}
38+
type=raw,value=latest
39+
40+
- name: Build and push
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: ./live_react_examples
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
include:
22-
- elixir: 1.18.1
23-
erlang: 27.2.0
22+
- elixir: 1.19.5
23+
erlang: 27.3.4.10
2424
name: Elixir v${{ matrix.elixir }}, Erlang v${{ matrix.erlang }}
2525
steps:
2626
- uses: actions/checkout@v4

lib/live_react/ssr.ex

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ defmodule LiveReact.SSR do
4141
mod ->
4242
meta = %{component: name, props: props, slots: slots}
4343

44-
body =
45-
:telemetry.span([:live_react, :ssr], meta, fn ->
46-
{mod.render(name, props, slots), meta}
47-
end)
48-
49-
with body when is_binary(body) <- body do
50-
case String.split(body, "<!-- preload -->", parts: 2) do
51-
[links, html] -> %{preloadLinks: links, html: html}
52-
[body] -> %{preloadLinks: "", html: body}
53-
end
54-
end
44+
:telemetry.span([:live_react, :ssr], meta, fn ->
45+
{mod.render(name, props, slots), meta}
46+
end)
47+
|> parse_render_body()
5548
end
5649
end
50+
51+
defp parse_render_body(body) when is_binary(body) do
52+
case String.split(body, "<!-- preload -->", parts: 2) do
53+
[links, html] -> %{preloadLinks: links, html: html}
54+
[html] -> %{preloadLinks: "", html: html}
55+
end
56+
end
57+
58+
defp parse_render_body(body), do: body
5759
end

live_react_examples/Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
# This file is based on these images:
88
#
99
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
10-
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20240612-slim - for the release image
10+
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bookworm-slim - for the release image
1111
# - https://pkgs.org/ - resource for finding needed packages
12-
# - Ex: hexpm/elixir:1.17.1-erlang-26.2.5.1-debian-bullseye-20240612-slim
12+
# - Ex: hexpm/elixir:1.18.1-erlang-27.2.0-debian-bookworm-20250113-slim
1313
#
14-
ARG ELIXIR_VERSION=1.17.3
15-
ARG OTP_VERSION=27.1.1
16-
ARG DEBIAN_VERSION=bookworm-20240926
14+
ARG ELIXIR_VERSION=1.19.5
15+
ARG OTP_VERSION=27.3.4.10
16+
ARG DEBIAN_VERSION=bookworm-20260406-slim
1717

1818
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
1919
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
2020

21-
FROM ${BUILDER_IMAGE} as builder
21+
FROM ${BUILDER_IMAGE} AS builder
2222

2323
# install build dependencies
2424
RUN apt-get update -y && apt-get install -y build-essential git curl \
2525
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
2626

2727
# install nodejs for build stage
28-
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && apt-get install -y nodejs
28+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
2929

3030
# prepare build dir
3131
WORKDIR /app
@@ -77,15 +77,15 @@ RUN apt-get update -y && \
7777
apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates curl \
7878
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
7979

80-
# install nodejs for production environment
81-
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && apt-get install -y nodejs
80+
# install nodejs for production environment (needed for SSR)
81+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
8282

8383
# Set the locale
8484
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
8585

86-
ENV LANG en_US.UTF-8
87-
ENV LANGUAGE en_US:en
88-
ENV LC_ALL en_US.UTF-8
86+
ENV LANG=en_US.UTF-8
87+
ENV LANGUAGE=en_US:en
88+
ENV LC_ALL=en_US.UTF-8
8989

9090
WORKDIR "/app"
9191
RUN chown nobody /app

live_react_examples/assets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"clsx": "^2.1.1",
2525
"framer-motion": "^11.2.11",
2626
"highlight.js": "^11.10.0",
27-
"live_react": "file:../..",
27+
"live_react": "file:../deps/live_react",
2828
"phoenix": "file:../deps/phoenix",
2929
"phoenix_html": "file:../deps/phoenix_html",
3030
"phoenix_live_view": "file:../deps/phoenix_live_view",

live_react_examples/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ defmodule LiveReactExamples.MixProject do
5252
{:dns_cluster, "~> 0.1.1"},
5353
{:bandit, "~> 1.5"},
5454
# For development
55-
{:live_react, path: ".."}
55+
# {:live_react, path: ".."}
5656
# For deployment
57-
# {:live_react, "~> 1.0.0"}
57+
{:live_react, "~> 1.1.0"}
5858
]
5959
end
6060

mix.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
%{
22
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
3-
"castore": {:hex, :castore, "1.0.14", "4582dd7d630b48cf5e1ca8d3d42494db51e406b7ba704e81fbd401866366896a", [:mix], [], "hexpm", "7bc1b65249d31701393edaaac18ec8398d8974d52c647b7904d01b964137b9f4"},
43
"credo": {:hex, :credo, "1.7.18", "5c5596bf7aedf9c8c227f13272ac499fe8eae6237bd326f2f07dfc173786f042", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a189d164685fd945809e862fe76a7420c4398fa288d76257662aecb909d6b3e5"},
54
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
65
"ex_doc": {:hex, :ex_doc, "0.40.3", "4a972ffe64bc07dc605af487e98fc19b72a4185f55ca031b94c0552d6071c1d9", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2756e357742fecd9749b489b85d67c9ce99c465f2e75728d9e6dc8d704b973de"},

0 commit comments

Comments
 (0)