Skip to content

Commit cdc0de8

Browse files
authored
Update everything and more (#562)
1 parent 693ba3a commit cdc0de8

38 files changed

+325
-243
lines changed

.credo.exs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
alias Credo.Check.Refactor.ABCSize
2+
13
%{
24
configs: [
35
%{
@@ -41,7 +43,7 @@
4143
{Credo.Check.Readability.VariableNames, []},
4244

4345
# Refactoring Opportunities
44-
{Credo.Check.Refactor.ABCSize, max_size: 40},
46+
{ABCSize, max_size: 40},
4547
{Credo.Check.Refactor.Apply, []},
4648
{Credo.Check.Refactor.CyclomaticComplexity, []},
4749
{Credo.Check.Refactor.FunctionArity, []},
@@ -107,7 +109,7 @@
107109
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
108110
{Credo.Check.Readability.WithCustomTaggedTuple, []},
109111
{Credo.Check.Readability.WithSingleClause, []},
110-
{Credo.Check.Refactor.ABCSize, []},
112+
{ABCSize, []},
111113
{Credo.Check.Refactor.AppendSingleItem, []},
112114
{Credo.Check.Refactor.CaseTrivialMatches, false},
113115
{Credo.Check.Refactor.CondStatements, []},

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ _build/
33
assets/node_modules/
44
deps/
55
test/
6+
priv/plts
67
priv/static/assets/
78

89
.*

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ npm-debug.log
1616
/assets/node_modules
1717

1818
# Ignore assets that are produced by build tools
19-
/priv/static/assets
20-
21-
# Ignore digested assets cache.
22-
/priv/static/cache_manifest.json
19+
/priv/static/*
20+
!/priv/static/favicon.svg
2321

2422
# Local environment variable files
2523
.env.local

.tool-versions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
erlang 26.0.2
2-
elixir 1.15.5-otp-26
3-
nodejs 20.5.1
1+
erlang 27.3.2
2+
elixir 1.18.3-otp-27
3+
nodejs 22.17.1

Dockerfile

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
ARG NODEJS_VERSION=22-bookworm-slim
2+
ARG ELIXIR_VERSION=1.18.1
3+
ARG OTP_VERSION=27.2
4+
ARG DEBIAN_VERSION=bookworm-20241223-slim
5+
6+
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
7+
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
8+
19
# -----------------------------------------------
210
# Stage: npm dependencies
311
# -----------------------------------------------
4-
FROM node:20.5-bookworm-slim AS npm-builder
12+
FROM node:${NODEJS_VERSION} AS npm-builder
513

614
# Install Debian dependencies
715
RUN apt-get update -y && \
@@ -16,44 +24,51 @@ COPY assets assets
1624
RUN npm ci --prefix assets
1725

1826
# -----------------------------------------------
19-
# Stage: hex dependencies
27+
# Stage: hex dependencies + OTP release
2028
# -----------------------------------------------
21-
FROM hexpm/elixir:1.15.5-erlang-26.0.2-debian-bookworm-20230612-slim AS otp-builder
29+
FROM ${BUILDER_IMAGE} AS hex-builder
2230

23-
# Install Debian dependencies
31+
# install build dependencies
2432
RUN apt-get update -y && \
2533
apt-get install -y build-essential git && \
2634
apt-get clean && \
2735
rm -f /var/lib/apt/lists/*_*
2836

37+
# prepare build dir
2938
WORKDIR /app
3039

31-
# Install Erlang dependencies
32-
RUN mix local.rebar --force && \
33-
mix local.hex --force
40+
ENV MIX_ENV=prod
41+
ENV ERL_FLAGS="+JPperf true"
42+
43+
# install hex + rebar
44+
RUN mix local.hex --force && \
45+
mix local.rebar --force
3446

47+
# set build ENV
3548
ENV MIX_ENV="prod"
3649

37-
# Install mix dependencies
50+
# install mix dependencies
3851
COPY mix.exs mix.lock ./
3952
RUN mix deps.get --only $MIX_ENV
4053

41-
# Copy compile-time config files before we compile dependencies
54+
# copy compile-time config files before we compile dependencies
4255
# to ensure any relevant config change will trigger the dependencies
4356
# to be re-compiled.
4457
RUN mkdir config
4558
COPY config/config.exs config/${MIX_ENV}.exs config/
46-
47-
# Compile mix dependencies
4859
RUN mix deps.compile
4960

50-
# Compile assets
61+
# install Esbuild so it is cached
62+
RUN mix esbuild.install --if-missing
63+
64+
COPY lib lib
5165
COPY --from=npm-builder /app/assets assets
5266
COPY priv priv
67+
68+
# Compile assets
5369
RUN mix assets.deploy
5470

55-
# Compile code
56-
COPY lib lib
71+
# Compile the release
5772
RUN mix compile
5873

5974
# Changes to config/runtime.exs don't require recompiling the code
@@ -65,25 +80,27 @@ RUN mix release
6580
# -----------------------------------------------
6681
# Stage: Bundle release in a docker image
6782
# -----------------------------------------------
68-
FROM debian:bookworm-20230612-slim
83+
FROM ${RUNNER_IMAGE}
6984

7085
RUN apt-get update -y && \
71-
apt-get install -y libstdc++6 openssl libncurses5 locales && \
72-
apt-get clean && \
73-
rm -f /var/lib/apt/lists/*_*
86+
apt-get install -y curl jq libstdc++6 openssl libncurses5 locales && \
87+
apt-get clean && \
88+
rm -f /var/lib/apt/lists/*_*
7489

7590
# Set the locale
7691
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
7792

78-
ENV LANG en_US.UTF-8
79-
ENV LANGUAGE en_US:en
80-
ENV LC_ALL en_US.UTF-8
81-
8293
WORKDIR "/app"
8394
RUN chown nobody /app
8495

96+
# set runner ENV
97+
ENV LANG=en_US.UTF-8
98+
ENV LANGUAGE=en_US:en
99+
ENV LC_ALL=en_US.UTF-8
100+
ENV MIX_ENV="prod"
101+
85102
# Only copy the final release from the build stage
86-
COPY --from=otp-builder --chown=nobody:root /app/_build/prod/rel/elixir_boilerplate ./
103+
COPY --from=hex-builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/elixir_boilerplate ./
87104

88105
USER nobody
89106

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ sync-translations: ## Synchronize translations with Accent
8888

8989
.PHONY: test
9090
test: ## Run the test suite
91-
mix test
91+
mix test --warnings-as-errors
9292

9393
# Check, lint and format targets
9494
# ------------------------------

assets/css/app.css

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
.home {
2-
display: flex;
3-
flex-direction: column;
4-
justify-content: center;
5-
align-items: center;
6-
padding: 40px;
7-
text-align: center;
1+
body {
82
font-family:
93
system-ui,
104
-apple-system,
@@ -19,6 +13,15 @@
1913
'Segoe UI Emoji',
2014
'Segoe UI Symbol',
2115
'Noto Color Emoji';
16+
}
17+
18+
.home {
19+
display: flex;
20+
flex-direction: column;
21+
justify-content: center;
22+
align-items: center;
23+
padding: 40px;
24+
text-align: center;
2225
line-height: 1.4;
2326
}
2427

@@ -36,8 +39,25 @@
3639
}
3740

3841
.flash-messages {
42+
display: flex;
3943
position: fixed;
40-
top: 0;
41-
right: 0;
44+
z-index: 1000;
45+
top: 5px;
46+
right: 5px;
47+
flex-direction: column;
48+
gap: 5px;
49+
}
50+
51+
#flash-success {
52+
padding: 10px;
53+
border: 1px solid rgb(62, 146, 62);
54+
background-color: #90d690;
55+
color: #123c12;
56+
}
57+
58+
#flash-error {
4259
padding: 10px;
60+
border: 1px solid rgb(144, 35, 35);
61+
background-color: #d68d8d;
62+
color: #3c1212;
4363
}

assets/js/app.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

assets/js/app.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import '../css/app.css';
2+
3+
import 'phoenix_html';
4+
5+
import * as phoenix from 'phoenix';
6+
import {LiveSocket} from 'phoenix_live_view';
7+
8+
interface Hook {
9+
mounted?(): void;
10+
destroyed?(): void;
11+
}
12+
13+
const Hooks: Record<string, Hook> = {};
14+
15+
const csrfToken = document
16+
.querySelector("meta[name='csrf-token']")
17+
?.getAttribute('content');
18+
19+
const liveSocket = new LiveSocket('/live', phoenix.Socket, {
20+
hooks: Hooks,
21+
params: {_csrf_token: csrfToken} // eslint-disable-line camelcase
22+
});
23+
24+
liveSocket.connect();

0 commit comments

Comments
 (0)