fix: Build assets as part of Docker build
This commit is contained in:
parent
696e312a8c
commit
24892db8fd
3 changed files with 24 additions and 5 deletions
18
Dockerfile
18
Dockerfile
|
@ -1,4 +1,4 @@
|
||||||
FROM elixir:1.8.0-alpine
|
FROM elixir:1.8.0-alpine AS elixir1
|
||||||
|
|
||||||
RUN apk add make gcc libc-dev
|
RUN apk add make gcc libc-dev
|
||||||
|
|
||||||
|
@ -30,7 +30,21 @@ RUN mix deps.compile
|
||||||
ADD ./script /root/app/script
|
ADD ./script /root/app/script
|
||||||
ADD ./apps /root/app/apps
|
ADD ./apps /root/app/apps
|
||||||
|
|
||||||
RUN mix phx.digest
|
|
||||||
RUN MAKE=cmake mix compile
|
RUN MAKE=cmake mix compile
|
||||||
|
|
||||||
|
FROM node:15.0
|
||||||
|
|
||||||
|
WORKDIR /root/app/apps/app/assets/
|
||||||
|
COPY --from=0 /root/app/apps/app/assets/ /root/app/apps/app/assets
|
||||||
|
COPY --from=0 /root/app/deps/phoenix/ /root/app/apps/app/assets/node_modules/phoenix
|
||||||
|
COPY --from=0 /root/app/deps/phoenix_html/ /root/app/apps/app/assets/node_modules/phoenix_html
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run deploy
|
||||||
|
|
||||||
|
FROM elixir1
|
||||||
|
|
||||||
|
COPY --from=1 /root/app/apps/app/priv/static/ /root/app/apps/app/priv/static
|
||||||
|
|
||||||
|
RUN mix phx.digest
|
||||||
|
|
||||||
CMD ["mix", "phx.server"]
|
CMD ["mix", "phx.server"]
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "webpack --mode production",
|
"deploy": "webpack --mode production",
|
||||||
"watch": "webpack --mode development --watch",
|
"watch": "webpack --mode development --watch",
|
||||||
"preinstall": "npx npm-force-resolutions",
|
|
||||||
"profile": "webpack --mode development --plugin webpack/lib/debug/ProfilingPlugin"
|
"profile": "webpack --mode development --plugin webpack/lib/debug/ProfilingPlugin"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -20,10 +20,15 @@ secret_key_base = System.get_env("SECRET_KEY_BASE")
|
||||||
]
|
]
|
||||||
|> Enum.map(fn {otp_app, module, start_server} ->
|
|> Enum.map(fn {otp_app, module, start_server} ->
|
||||||
endpoint = Module.concat(module, "Endpoint")
|
endpoint = Module.concat(module, "Endpoint")
|
||||||
|
extra_opts =
|
||||||
|
if start_server do
|
||||||
|
[cache_static_manifest: "priv/static/cache_manifest.json"]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
config otp_app, endpoint,
|
config otp_app, endpoint, [
|
||||||
url: [host: "example.com", port: 80],
|
url: [host: "example.com", port: 80],
|
||||||
cache_static_manifest: "priv/static/cache_manifest.json",
|
|
||||||
http: [
|
http: [
|
||||||
port: String.to_integer(System.get_env("PORT") || "4000"),
|
port: String.to_integer(System.get_env("PORT") || "4000"),
|
||||||
transport_options: [socket_opts: [:inet6]]
|
transport_options: [socket_opts: [:inet6]]
|
||||||
|
@ -32,6 +37,7 @@ secret_key_base = System.get_env("SECRET_KEY_BASE")
|
||||||
pubsub_server: App.PubSub,
|
pubsub_server: App.PubSub,
|
||||||
live_view: [signing_salt: "g5ltUbnQ"],
|
live_view: [signing_salt: "g5ltUbnQ"],
|
||||||
server: start_server
|
server: start_server
|
||||||
|
] ++ extra_opts
|
||||||
end)
|
end)
|
||||||
|
|
||||||
# ## Using releases (Elixir v1.9+)
|
# ## Using releases (Elixir v1.9+)
|
||||||
|
|
Loading…
Reference in a new issue