Papillon6814

Papillon6814

Hello. I’m using pigeon for sending notifications to iOS devices. And I use docker for deploying phoenix project on Ubuntu.

I can send notifications to my device in local environment, but in a container, it fails to start an application.

FROM elixir:1.9.4-alpine AS build

RUN apk add --no-cache build-base npm git python

WORKDIR /app

RUN mix local.hex --force && \
    mix local.rebar --force

ENV DATABASE_URL=ecto://postgres:postgres@db/pappap
ENV SECRET_KEY_BASE=uTG/s/VxvRixaWqRdW1MrtOqGxAUL/m3VIA5HZAaMHvU/PixTV5V+vUeWhv5UEnY
ENV MIX_ENV=prod

COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile

COPY priv priv
RUN ls priv/cert
COPY lib lib
#COPY rel rel
RUN mix compile
#RUN mix ecto.create
#RUN mix ecto.migrate
RUN mix release

FROM alpine:3.9 AS app
RUN apk add --no-cache openssl ncurses-libs

WORKDIR /app

RUN chown nobody:nobody /app

USER nobody:nobody

COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/pappap ./

ENV HOME=/app

COPY ./entrypoint.sh .
RUN ls lib

USER root

RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

This is my Dockerfile of the application. It copies priv directory. My AuthKey is in it.

version: '3'

networks:
  backend:
    driver: bridge

services:
  db:
    build: ./dockerfiles/db
    volumes:
      - ./volumes/db/data:/var/lib/postgresql/0.1.0
    ports:
      - 5432:5432
    environment:
      - POSTGRES_DB=pappap
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    restart: always
    networks:
      - backend

  app:
    build:
      dockerfile: ./dockerfiles/app/Dockerfile
      context: .
    command: "bin/pappap start"
    environment:
      - DATABASE_URL=ecto://postgres:postgres@db/pappap
      - SECRET_KEY_BASE=tIQIht+gvi3rto8AHxzjr7WfqltNPBXWb4HnYzBS/tw0vBldMvSsxFe1rdpoOkYc
    ports:
      - 4001:4001
    tty: true
    networks:
      - backend

And this is my docker-compose.yml. I create image and container from them.
I create them with docker-compose build and docker-compose up -d db, then docker-compose up -d app.

Although the db container works, the app one does not work…
Log of the app container is

d logs pappap_app_1 --tail all                 20:09
11:09:50.550 [info] == Running 20200827152435 Pappap.Repo.Migrations.CreateDevices.change/0 forward
11:09:50.553 [info] create table devices
11:09:50.559 [info] create index devices_device_id_index
11:09:50.568 [info] == Migrated 20200827152435 in 0.0s
11:09:50.600 [info] == Running 20201023070157 Pappap.Repo.Migrations.CreateScheduler.change/0 forward
11:09:50.600 [info] create table notification_scheduler
11:09:50.604 [info] == Migrated 20201023070157 in 0.0s
11:09:52.745 [info] Application pigeon exited: Pigeon.start(:normal, []) returned an error: shutdown: failed to start child: :apns_default
    ** (EXIT) an exception was raised:
        ** (Pigeon.ConfigError) attempted to start without valid key

The following configuration was given:

%Pigeon.APNS.JWTConfig{
  key: {:error, {:invalid, "priv/cert/AuthKey_XXXXXp8"}},
  key_identifier: "XXXXX",
  keyfile: {:error, {:nofile, "priv/cert/AuthKey_XXXXX.p8"}},
  name: :apns_default,
  ping_period: 600000,
  port: 443,
  reconnect: false,
  team_id: "AAAAA",
  uri: "api.push.apple.com"
}

(pigeon) lib/pigeon/apns/jwt_config.ex:205: Pigeon.Configurable.Pigeon.APNS.JWTConfig.validate!/1
(pigeon) lib/pigeon/worker.ex:44: Pigeon.Worker.init/1
(gen_stage) lib/gen_stage.ex:1704: GenStage.init/1
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
{"Kernel pid terminated",application_controller,"{application_start_failure,pigeon,{{shutdown,{failed_to_start_child,apns_default,{#{'__exception__' => true,'__struct__' => 'Elixir.Pigeon.ConfigError',config => #{'__struct__' => 'Elixir.Pigeon.APNS.JWTConfig',key => {error,{invalid,<<\"priv/cert/AuthKey_XXXXX.p8\">>}},key_identifier => <<\"XXXXX\">>,keyfile => {error,{nofile,<<\"priv/cert/AuthKey_XXXXX.p8\">>}},name => apns_default,ping_period => 600000,port => 443,reconnect => false,team_id => <<\"AAAAA\">>,uri => <<\"api.push.apple.com\">>},reason => <<\"attempted to start without valid key\">>},[{'Elixir.Pigeon.Configurable.Pigeon.APNS.JWTConfig','validate!',1,[{file,\"lib/pigeon/apns/jwt_config.ex\"},{line,205}]},{'Elixir.Pigeon.Worker',init,1,[{file,\"lib/pigeon/worker.ex\"},{line,44}]},{'Elixir.GenStage',init,1,[{file,\"lib/gen_stage.ex\"},{line,1704}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,374}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,249}]}]}}},{'Elixir.Pigeon',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,pigeon,{{shutdown,{failed_to_start_child,apns_default,{#{'__exception__' => true,'__struct__' => 'Elixir.Pigeon.ConfigError',

Crash dump is being written to: erl_crash.dump...done

I don’t know what is wrong… I’ll show you anything if it’s necessary for getting deployment well.
HELP!

Showing Posts 1 to 3

lucaong

lucaong

I have no experience with Pigeon, but the error seems to indicate that you are providing an invalid key:

My recommendation is to double-check your :key and :keyfile, and make sure they are valid.

NobbZ

NobbZ

It seems as if you are using relative pathes for the key file, you need to use an absolute path using :code priv_dir or how the function was called.

Papillon6814

Papillon6814 OP

Thank you!
It was a path problem as you said!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews