Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Elixir and Phoenix and all deps #395

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
[]
[
{"lib/phoenix_starter/workers/reportable.ex", :extra_range, 30},
{"lib/phoenix_starter/workers/error_reporter.ex", :guard_fail, 19},
{"lib/phoenix_starter_web/controllers/user_registration_controller.ex", :pattern_match, 16}
]
19 changes: 13 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
_build/
.git/
*.ez
.*
.elixir_ls/
.git/
/priv/static/assets/
/priv/static/cache_manifest.json
Dockerfile
README.md
_build/
assets/node_modules/
cover/
deps/
doc/
erl_crash.dump
priv/static
test
README.md
Dockerfile
.*
test/
tmp/

5 changes: 3 additions & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
import_deps: [:ecto, :phoenix],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"]
inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter]
]
37 changes: 13 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

strategy:
matrix:
elixir: ["1.13.2"]
otp: ["24.2.1"]
elixir: ["1.13.4"]
otp: ["25.0.3"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -55,9 +55,9 @@ jobs:

strategy:
matrix:
elixir: ["1.13.2"]
otp: ["24.2.1"]
node: ["14.13.1"]
elixir: ["1.13.4"]
otp: ["25.0.3"]
node: ["18.7.0"]

steps:
- uses: actions/checkout@v2
Expand All @@ -82,16 +82,7 @@ jobs:

- name: Install Node dependencies
run: npm --prefix assets ci
- run: npx prettier --check .
working-directory: ./assets
- run: npx stylelint "css/*"
working-directory: ./assets
- run: npx eslint js --ext .js,.jsx,.ts,.tsx
working-directory: ./assets
- run: npm run deploy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was running web pack, which we no longer need to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngscheurich Is there a lint we can run for Typescript to ensure our types pass? I think this deploy step was added to get the TS checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, esbuild does not do any type-checking so we'll still need to depend on the typescript package and run npx tsc --noEmit in CI.

env:
NODE_ENV: production
working-directory: ./assets
- run: npm --prefix assets run ci

lint:
name: Lint
Expand All @@ -102,8 +93,8 @@ jobs:

strategy:
matrix:
elixir: ["1.13.2"]
otp: ["24.2.1"]
elixir: ["1.13.4"]
otp: ["25.0.3"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -141,8 +132,8 @@ jobs:

strategy:
matrix:
elixir: ["1.13.2"]
otp: ["24.2.1"]
elixir: ["1.13.4"]
otp: ["25.0.3"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -174,9 +165,7 @@ jobs:

- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed, Dialyxir does this automatically now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mix dialyzer --plt
run: mix dialyzer --plt

- run: mix dialyzer --no-check --format github

Expand All @@ -190,8 +179,8 @@ jobs:

strategy:
matrix:
elixir: ["1.13.2"]
otp: ["24.2.1"]
elixir: ["1.13.4"]
otp: ["25.0.3"]

services:
db:
Expand Down
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
phoenix_starter-*.tar

# Ignore assets that are produced by build tools.
/priv/static/assets/

# Ignore digested assets cache.
/priv/static/cache_manifest.json

# If NPM crashes, it generates a log, let's ignore it too.
npm-debug.log

# The directory NPM downloads your dependencies sources to.
/assets/node_modules/

# Since we are building assets from assets/,
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/

# Ignore Dialyzer PLTs
/priv/plts/*.plt
/priv/plts/*.plt.hash
6 changes: 3 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
erlang 24.2.1
elixir 1.13.2-otp-24
nodejs 16.13.2
erlang 25.0.3
elixir 1.13.4-otp-25
nodejs 18.7.0
22 changes: 15 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ ENV MIX_ENV=prod

WORKDIR /opt/app

COPY config config
COPY mix.* ./
RUN mix do deps.get --only=$MIX_ENV, deps.compile
COPY mix.exs mix.lock ./
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are mostly due to how Docker caches. Each line creates a new layer. Based on what needs to be recompiled, separating some steps and copying at different points helps maximize the Docker cache, which speeds up the build.

These are picked up from the new Phoenix default Dockerfile.

RUN mix deps.get --only=$MIX_ENV

COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile

# Assets builder
# ---------------
Expand All @@ -52,8 +54,15 @@ WORKDIR /opt/app
COPY --from=assets-build /opt/app/priv/static priv/static
RUN mix phx.digest

COPY . .
RUN mix do compile, deps.compile sentry --force, release --quiet
COPY priv priv
COPY lib lib

RUN mix do compile, deps.compile sentry --force

COPY config/runtime.exs config/
COPY rel rel

RUN mix release

# App final
# ---------
Expand All @@ -70,8 +79,7 @@ RUN apk --no-cache --update add \

WORKDIR /opt/app

COPY --from=release /opt/app/_build/prod/rel/phoenix_starter ./
RUN chown -R nobody: /opt/app
COPY --from=release --chown=nobody: /opt/app/_build/prod/rel/phoenix_starter ./
USER nobody

EXPOSE ${PORT}
Expand Down
3 changes: 3 additions & 0 deletions assets/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.eslintrc.js
postcss.config.js
tailwind.config.js
2 changes: 1 addition & 1 deletion assets/.stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
"at-rule-no-unknown": [
true,
{
ignoreAtRules: ["define-mixin", "mixin", "layer"],
ignoreAtRules: ["apply", "define-mixin", "mixin", "layer"],
},
],
"declaration-colon-newline-after": "always-multi-line",
Expand Down
24 changes: 9 additions & 15 deletions assets/js/app.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
import "../css/app.css"

// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
// in "webpack.config.js".
//
// Import deps with the dep name or local files with a relative path, for example:
//
// import {Socket} from "phoenix"
// import socket from "./socket"
//
import "phoenix_html"
import "alpinejs"
import Alpine from "alpinejs"
import { Socket } from "phoenix"
import NProgress from "nprogress"
import { LiveSocket } from "phoenix_live_view"
Expand All @@ -32,19 +23,22 @@ interface Alpine {

interface AlpineHTMLElement {
__x?: unknown
_x_dataStack?: unknown
}

// Initialize Alpine
window.Alpine = Alpine
Alpine.start()

const csrfTokenTag = document.querySelector("meta[name='csrf-token']")
const csrfToken = csrfTokenTag ? csrfTokenTag.getAttribute("content") : ""
const liveSocket = new LiveSocket("/live", Socket, {
dom: {
onBeforeElUpdated(from, to) {
if ((from as AlpineHTMLElement).__x) {
window.Alpine.clone((from as AlpineHTMLElement).__x, to)
return false
if ((from as AlpineHTMLElement)._x_dataStack) {
window.Alpine.clone(from, to)
}

return false
return true
},
},
params: { _csrf_token: csrfToken },
Expand Down
Loading