I have deployed my learning/tools project on Render.com.
However, I’m running into an issue. I have used custom Fonts for my site, which works in dev and production build locally, however, when I deploy it using Render, it fails.
check the folder where your assets are getting built to, also make sure that folder is served by the static endpoint, you can find the configuration in endpoint.ex
Yeah those static paths ( DerpyToolsWeb.static_paths() ) don’t look default to me, however I didn’t use phoenix in quite long time, maybe they define paths in a different module now.
Exactly the same commands that are being used on Render.
In local prod build, the file digestion works as expected and files have gibberish names like: url(/fonts/barriecito-94c9ab0c4e14aa8632e6f0f13bd5dfbb.ttf?vsn=d)
In render prod build, the file digestion doesn’t work as expected, and not all files have gibberish name: url(/fonts/barriecito.ttf)
I don’t see how that’s the config’s fault. Maybe I’m missing missing something in the bash script, or I don’t know.
It seems to be the case, I don’t remember what those hashes are used after the name for, but it would be definitely a red flag if they were to appear in production as things such as subresources integrity are in a different format: Subresource Integrity - Security on the web | MDN
Say the browser caches a resource named app.css. Next time, if I make changes to some CSS in app.css. The browser will continue to pick the cached value.
However, with modern build tools, hashes are attached to the end of file names, i.e. app-gibberish-hash.css. So the browser will download the modified CSS, and the latest changes will show up in the front end.
Subresource Integrity is a different thing. It’s like checking if the javascript we linked to in our site, is indeed the original one and has not been tampered with.
No problem, I have a feeling that browser is doing too many things these days, and it will end the same way as the other concurrents, there is so much you can abstract, as the implementation will always differ, and shifting this into the browser territory is a dangerous game.
It still breaks, and the fonts don’t get digested.
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian
# instead of Alpine to avoid DNS resolution issues in production.
#
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
# https://hub.docker.com/_/ubuntu?tab=tags
#
# This file is based on these images:
#
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20230612-slim - for the release image
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.15.4-erlang-26.0.2-debian-bullseye-20230612-slim
#
ARG ELIXIR_VERSION=1.15.4
ARG OTP_VERSION=26.0.2
ARG DEBIAN_VERSION=bullseye-20230612-slim
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} as builder
# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# prepare build dir
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV="prod"
# install mix dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config
# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
COPY priv priv
COPY lib lib
COPY assets assets
# compile assets
RUN mix assets.deploy
# Compile the release
RUN mix compile
# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/
COPY rel rel
RUN mix release
# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}
RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR "/app"
RUN chown nobody /app
# set runner ENV
ENV MIX_ENV="prod"
# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/derpy_tools ./
USER nobody
CMD ["sh", "-c", "/app/bin/migrate && /app/bin/server"]