Lyolik M
Lyolik M

Reputation: 1

Can't deploy two-service docker image to google app engine

I've built a docker image which consists of two parts:

I know that it's better to run those two parts in different containers, but there is a reason to keep them in one. So I found a way how to run two services in one container with the use of supervisord.

In the dockerfile I expose 8080, and when I run the docker image locally it works just fine. I can make POST requests to nodejs app, which in its turn is making POST request to the haskellmodule using port 8000. I run it with the following command:

docker run -p 8080:8080 image_name

So I pushed the image to google container registry and deployed it with the use of --image-url flag. The deployment process goes without any error, though after that I cannot reach my app. If I look to the running version's logs, I see the following:

A  /usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
A    'Supervisord is running as root and it is searching '
A  2017-10-08 14:08:45,368 CRIT Supervisor running as root (no user in config file)
A  2017-10-08 14:08:45,368 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
A  2017-10-08 14:08:45,423 INFO RPC interface 'supervisor' initialized
A  2017-10-08 14:08:45,423 CRIT Server 'unix_http_server' running without any HTTP authentication checking

A  2017-10-08 14:08:45,424 INFO supervisord started with pid 1
A  2017-10-08 14:08:46,425 INFO spawned: 'haskellmodule' with pid 7
A  2017-10-08 14:08:46,427 INFO spawned: 'nodesrv' with pid 8
A  2017-10-08 14:08:47,429 INFO success: haskellmodule entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
A  2017-10-08 14:08:47,429 INFO success: nodesrv entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A  2017-10-08 14:13:49,124 WARN received SIGTERM indicating exit request
A  2017-10-08 14:13:49,127 INFO waiting for haskellmodule, nodesrv to die
A  2017-10-08 14:13:49,128 INFO stopped: nodesrv (terminated by SIGTERM)
A  2017-10-08 14:13:49,138 INFO stopped: haskellmodule (terminated by SIGTERM)

Then it starts over and everything is repeated over and over again.

My Dockerfile:

FROM node:latest
RUN apt-get update
RUN curl -sSL https://get.haskellstack.org/ | sh
COPY ./nodesrv /nodesrv
COPY ./haskellmodule /haskellmodule 
RUN mkdir /log
WORKDIR /haskellmodule
RUN stack build
WORKDIR /
RUN apt-get update && apt-get install -y supervisor
ADD ./configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 8080
ENTRYPOINT ["/usr/bin/supervisord"]

My supervisord config:

[supervisord]
nodaemon=true

[program:nodesrv]
command=node index.js
directory=/nodesrv/
user=root

[program:haskellmodule]
command=stack exec haskellmodule-exe
directory=/haskellmodule/
user=root

My app.yaml file I use for deployment:

runtime: custom
env: flex

So seems like google app engine is shutting supervisor down (taking into account that everything is working on localhost). What could be a reason of that?

Thanks in advance

Upvotes: 0

Views: 557

Answers (2)

Kunal Chawla
Kunal Chawla

Reputation: 119

Run supervisord with -n argument.

This will run supervisor in foreground.

Works fine for me in app engine flexible environment.

Thanks

Upvotes: 0

speedplane
speedplane

Reputation: 16141

You need to configure your app.yaml file to open ports 8080 and 8000. You need to do this in addition to opening the port in your Dockerfile with EXPOSE. The documentation for how to setup your app.yaml file is located here, and the example from the docs is copied below:

Add the following to your app.yaml:

network:
  instance_tag: TAG_NAME
  name: NETWORK_NAME
  subnetwork_name: SUBNETWORK_NAME
  forwarded_ports:
    - PORT
    - HOST_PORT:CONTAINER_PORT
    - PORT/tcp
    - HOST_PORT:CONTAINER_PORT/udp

Upvotes: 0

Related Questions