Hi guys, totally new here. I’m trying to create a blog-like API using Phoenix. But the thing is when I try to mount a volume to store the file uploads, I couldn’t do it although I have followed the tutorial in the docs.
Here are the steps that I have done:
- Creating the app
- Create the postgres and attach it to the app
- Deploy the app, it works with the db
- Create the volume
- Add the mounts section in fly.toml, try to deploy again
- App running the release script, it says setting up volume ‘volume_name’
- Error: release command failed, deployment aborted
And of course, it only fails when I add the volume. I remove the mounts section then it works just fine.
For the context, I’ll paste the Dockerfile and the fly.toml here. Hope someone can help. Thanks.
###
### Fist Stage - Building the Release
###
FROM hexpm/elixir:1.12.1-erlang-24.0.1-alpine-3.13.3 AS build
# install build dependencies
RUN apk add --no-cache build-base
# prepare build dir
WORKDIR /app
# extend hex timeout
ENV HEX_HTTP_TIMEOUT=20
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV as prod
ENV MIX_ENV=prod
ENV SECRET_KEY_BASE=nokey
# Copy over the mix.exs and mix.lock files to load the dependencies. If those
# files don't change, then we don't keep re-fetching and rebuilding the deps.
COPY mix.exs mix.lock ./
COPY config config
RUN mix deps.get --only prod && \
mix deps.compile
# install npm dependencies
# COPY assets/package.json assets/package-lock.json ./assets/
# RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
COPY priv priv
COPY assets assets
# NOTE: If using TailwindCSS, it uses a special "purge" step and that requires
# the code in `lib` to see what is being used. Uncomment that here before
# running the npm deploy script if that's the case.
# COPY lib lib
# build assets
# RUN npm run --prefix ./assets deploy
RUN mix phx.digest
# copy source here if not using TailwindCSS
COPY lib lib
# compile and build release
COPY rel rel
RUN mix do compile, release
###
### Second Stage - Setup the Runtime Environment
###
# prepare release docker image
FROM alpine:3.13.3 AS app
RUN apk add --no-cache libstdc++ openssl ncurses-libs
WORKDIR /app
RUN chown nobody:nobody /app
USER nobody:nobody
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/behalf_be_phoenix ./
RUN mkdir -p /app/photos/
ENV HOME=/app
ENV MIX_ENV=prod
ENV SECRET_KEY_BASE=nokey
ENV PORT=4000
CMD ["bin/behalf_be_phoenix", "start"]
# fly.toml file generated for behalf-be-phoenix on 2021-10-21T15:51:33+07:00
app = "behalf-be-phoenix"
kill_signal = "SIGTERM"
kill_timeout = 5
[env]
[deploy]
release_command = "/app/bin/behalf_be_phoenix eval BehalfBePhoenix.Release.migrate"
[mounts]
source="behalf_storage"
destination="/app/photos"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 4000
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "30s"
interval = "15s"
restart_limit = 6
timeout = "2s"