I am trying to deploy my minio server to heroku. This is my Dockerfile:
FROM minio/minio
ENV MINIO_ACCESS_KEY="xxxxxx"
ENV MINIO_SECRET_KEY="xxxxxxxx"
CMD ["server", "/data"]
EXPOSE 9000
This works locally when I build and run it through docker (using these commands:)
docker build . -t testheroku
sudo docker run -p 8080:8080 testheroku
The Dockerfile is the only file in the directory.
Then, I try to push it to heroku. I followed the commands on the heroku docker instruction page to install the heroku container plugin, login, etc. Then, I pushed my app with: heroku container:push web --app APP_NAME
When I visit the app, I get an application error in browser. This is what the heroku logs display:
2017-09-21T02:24:47.589576+00:00 app[api]: Deployed web (26b84915ed48) by user []
2017-09-21T02:24:47.589576+00:00 app[api]: Release v28 created by user []
2017-09-21T02:24:48.241050+00:00 heroku[web.1]: State changed from crashed to starting
2017-09-21T02:24:49.480733+00:00 heroku[web.1]: Starting process with command `server /data`
2017-09-21T02:24:51.961825+00:00 app[web.1]: ‘server /data’ is not a minio sub-command. See ‘minio --help’.
2017-09-21T02:24:52.056706+00:00 heroku[web.1]: Process exited with status 1
2017-09-21T02:24:52.064400+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-21T02:24:52.938136+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=APP_NAME.herokuapp.com request_id=80ddd6f8-c053-4ff6-b4c9-fdb0ce8a48a5 fwd="67.245.14.153" dyno= connect= service= status=503 bytes= protocol=https
2017-09-21T02:24:54.319660+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=APP_NAME.herokuapp.com request_id=9988b6af-8a91-4e77-9bd4-c79c9e2ec24c fwd="67.245.14.153" dyno= connect= service= status=503 bytes= protocol=https
For those unfamiliar with minio, some explanation of ‘server /data’ is not a minio sub-command. See ‘minio --help’.: this shows when you run the minio command with an argument that isn't a minio command. For example,
./minio sadf
‘sadf’ is not a minio sub-command. See ‘minio --help’.
So what heroku is telling me is that it's interpreting the CMD line from my Dockerfile, not as it should (which is with server as the minio subcommand and /data as its argument) but instead, if you notice the quotation marks, heroku is smashing the two pieces together and attempting to use the whole string as a minio subcommand - hence the error message. It's trying to run the command minio 'server /data' instead of minio server /data
Has anyone seen this kind of behavior from heroku before with a Dockerfile? How can I make sure that the CMD line gets interpreted correctly, and not as one full string? I assume this is a heroku issue because it runs fine locally. Any advice would be welcome.
I had a similar issue that seemed to be caused by having other ENTRYPOINTS in the parent layers. To solve this, I added ENTRYPOINT [] above my CMD and everything worked fine.
Actually, I had the same issue.
This Dockerfile works fine.
FROM minio/minio:RELEASE.2022-01-08T03-11-54Z.fips
ENV MINIO_ROOT_USER=XXXXXX
ENV MINIO_ROOT_PASSWORD=XXXXXX
EXPOSE 9000
EXPOSE 9001
ENTRYPOINT ["minio"]
CMD ["server","/data","--console-address",":9001"]
Related
I have a docker container that runs perfectly when I build and run it in the local environment. But somehow when I deploy it to Heroku with container registry I get error code=H14 desc="No web processes running" method=POST path="/" host=mighty-river-17352.herokuapp.com request_id=e00ac035-9ba7-4127-a1c2-e72b718d9635 fwd="85.153.236.42" dyno= connect= service= status=503 bytes= protocol=https in the logs.
my file structure:
Dockerfile:
Main.go:
func main() {
port := os.Getenv("PORT")
http.HandleFunc("/", HelloServer)
log.Printf("Server started at port %s ", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
I've been looking for few days many tutorials to try to find my solution but i just can't get it.
Overview :
Im building an Asp.net Core (3.1) app which i've set up for running on docker. My goal is to deploy it to heroku.
Problem :
I can make it work on local to try with a docker container run but when i deploy it to heroku (the image was created without troubles) i get the error screen message:
"Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command"
Setup
Heroku :
dyno in use : api /bin/sh -c ASPNETCORE_URLS\=http://*:\$PORT\ dotnet\
build pack : https://github.com/jincod/dotnetcore-buildpack
Code
Dockerfile
WORKDIR /src
COPY *.sln .
COPY Ecomm.UnitTests/*.csproj Ecomm.UnitTests/
COPY Ecomm.Api/*.csproj Ecomm.Api/
RUN dotnet restore
COPY . .
# testing
FROM build AS testing
WORKDIR /src/Ecomm.Api
RUN dotnet build
WORKDIR /src/Ecomm.UnitTests
RUN dotnet test
# publish
FROM build AS publish
WORKDIR /src/Ecomm.Api
RUN dotnet publish -c Release -o /src/publish
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /src
COPY --from=publish /src/publish .
# heroku uses the following
CMD ASPNETCORE_URLS=http://*:$PORT dotnet Ecomm.Api.dll
Program.cs (default script)
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
Startup.cs (default script)
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
Launchsettings.json
"Ecomm.Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "/weatherforecast",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
Comparaison between running a container locally and deploy to heroku
Local interface
Heroku interface
methods used to push on Heroku container register:
docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
heroku container:push api -a $HEROKU_APP_NAME --recursive
heroku container:release api -a $HEROKU_APP_NAME
Errors logs in heroku :
2020-01-18T14:53:32.255720+00:00 heroku[api.1]: State changed from crashed to starting
2020-01-18T14:53:35.853732+00:00 heroku[api.1]: Starting process with command `/bin/sh -c ASPNETCORE_URLS\=http://\*:\59573\ dotnet\ Ecomm.Api.dll`
2020-01-18T14:53:36.494742+00:00 heroku[api.1]: State changed from starting to up
2020-01-18T14:53:37.754733+00:00 app[api.1]: Hosting environment: Production
2020-01-18T14:53:37.754802+00:00 app[api.1]: Content root path: /src
2020-01-18T14:53:37.754925+00:00 app[api.1]: Now listening on: http://[::]:59573
2020-01-18T14:53:37.754946+00:00 app[api.1]: Application started. Press Ctrl+C to shut down.
2020-01-18T14:53:39.762409+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=dariorega-ecomm-api.herokuapp.com request_id=7538ce41-5d5e-4081-b214-eb1e50fdcc6c fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
2020-01-18T14:53:40.075446+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=dariorega-ecomm-api.herokuapp.com request_id=4f1ff94a-eb45-4301-9c3a-74ece82abe84 fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
2020-01-18T14:53:51.155230+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/api" host=dariorega-ecomm-api.herokuapp.com request_id=1cc3eeac-1ce5-4a67-82e0-ee680beecc90 fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
2020-01-18T14:53:51.440188+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=dariorega-ecomm-api.herokuapp.com request_id=caa51bcd-a153-444b-88b5-c024d1b2ae84 fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
2020-01-18T14:53:56.045125+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/weatherforecast" host=dariorega-ecomm-api.herokuapp.com request_id=bcdc8195-9da6-4258-a48b-4614d885302a fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
2020-01-18T14:53:56.292724+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=dariorega-ecomm-api.herokuapp.com request_id=2329aa44-bdb0-43e3-bbbf-58bd87a09f8c fwd="188.155.40.41" dyno= connect= service= status=503 bytes= protocol=https
Logs i get in local container :
after running a docker container run with that same dockerfile :
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /src
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect
But it works
Conclusion
I've tried many things in the docker file or to edit the program.cs defining useUrl methods but i still can't make it work. I don't know if something is related beceause of the http /https process since the https isnt setup/working. And heroku use https.
Or should i define an url somehwere ?, any help welcome !
Thanks in advance for your time taken reading this
Try to setup HttpsRedirection https://github.com/jincod/AspNetCoreDemoApp/blob/master/src/AspNetCoreDemoApp/Startup.cs#L13 and ForwardedHeadersOptions https://github.com/jincod/AspNetCoreDemoApp/blob/master/src/AspNetCoreDemoApp/Startup.cs#L23-L29
P.S.: you use container deployment without dotnetcore-buildpack:)
I got the couchdb image from docker (https://hub.docker.com/_/couchdb) and then i run the follow commands:
docker run -p 5984:5984 -d --name my-couchdb2 couchdb:latest
docker commit 1d329ef7c516 registry.heroku.com/coucherte/web
docker tag my-couchdb2 registry.heroku.com/coucherte/web
docker push registry.heroku.com/coucherte/web
heroku container:release web --app coucherte
After this the dyno crashes, with "heroku logs --app coucherte" i get this log:
2019-02-28T17:55:15.064991+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=coucherte.herokuapp.com request_id=b875a9ce-6b45-4e37-b0fa-9a0ff243b5de fwd="177.251.168.219" dyno= connect= service= status=503 bytes= protocol=http
2019-02-28T17:55:15.542527+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=coucherte.herokuapp.com request_id=291c7afd-0e7d-41f2-846e-6555dbdb4621 fwd="177.251.168.219" dyno= connect= service= status=503 bytes= protocol=http
2019-02-28T18:00:23.647796+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-28T18:00:27.580280+00:00 heroku[web.1]: Starting process with command `/opt/couchdb/bin/couchdb`
2019-02-28T18:00:28.727119+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-28T18:00:28.670713+00:00 app[web.1]: [WARN tini (4)] Tini is not running as PID 1 and isn't registered as a child subreaper.
2019-02-28T18:00:28.670738+00:00 app[web.1]: Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
2019-02-28T18:00:28.670753+00:00 app[web.1]: To fix the problem, use the -s option or set the environment variable TINI_SUBREAPER to register Tini as a child subreaper, or run Tini as PID 1.
2019-02-28T18:00:28.674975+00:00 app[web.1]: find: 'couchdb' is not the name of a known user
2019-02-28T18:00:28.727539+00:00 heroku[web.1]: Process exited with status 1
2019-02-28T18:02:42.410954+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-28T18:02:51.032603+00:00 heroku[web.1]: Starting process with command `/opt/couchdb/bin/couchdb`
2019-02-28T18:02:53.540759+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-28T18:02:53.517057+00:00 heroku[web.1]: Process exited with status 1
2019-02-28T18:02:53.453924+00:00 app[web.1]: [WARN tini (4)] Tini is not running as PID 1 and isn't registered as a child subreaper.
2019-02-28T18:02:53.453944+00:00 app[web.1]: Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
2019-02-28T18:02:53.453960+00:00 app[web.1]: To fix the problem, use the -s option or set the environment variable TINI_SUBREAPER to register Tini as a child subreaper, or run Tini as PID 1.
2019-02-28T18:02:53.454218+00:00 app[web.1]: find: 'couchdb' is not the name of a known user
What i am doing wrong? How i have to change the PORT for Heroku? Do i have to change couchdb settings to work with HTTPS when working with Heroku?
UPDATE
I now figured out that inside the image in the root directory there is a file called docker-entrypoint.sh. In this file there is this line:
find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
So on this line i think it crashes in heroku. So there is a problem with the user couchdb. Localy it works and i can find the user with:
cut -d: -f1 /etc/passwd
but on heroku the user does not exist or cannot be found. Why?
UPDATE 2
The answer is here: https://github.com/apache/couchdb-docker/issues/136
I am trying to deploy an app https://github.com/valasek/timesheet on Heroku using a docker image.
App has a go backend (negroni/gorilla) and Vue.js/Vuetify.js on the frontend and is using PostgreSQL persistence.
I am stuck on deployment. I do not know how to debug, how to show the command line output, what is failing ... and any help highly appreciated.
Relevant Dockerfile - https://github.com/valasek/timesheet/blob/master/Dockerfile
Here are the steps I am doing:
> docker build --rm -f "Dockerfile" -t timesheet:latest .
Successfully tagged timesheet:latest
...
> heroku container:push timesheet:latest --app timesheet-cloud
...
The push refers to repository [registry.heroku.com/timesheet-cloud/timesheet]
...
Your image has been successfully pushed. You can now release it with the 'container:release' command.
> heroku container:release timesheet --app timesheet-cloud
Releasing images timesheet to timesheet-cloud... done
> heroku ps -a timesheet-cloud
Free dyno hours quota remaining this month: 971h 8m (97%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
No dynos on ⬢ timesheet-cloud
> heroku logs --app timesheet-cloud
2019-02-15T08:33:49.373221+00:00 app[api]: Deployed timesheet (709022e100f9) by user <email-reducted>#gmail.com
2019-02-15T08:33:49.373221+00:00 app[api]: Release v20 created by user <email-reducted>#gmail.com
2019-02-15T08:34:43.901070+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=timesheet-cloud.herokuapp.com request_id=4c21eb79-5344-4d40-b341-8977128c873f fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:44.842322+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=timesheet-cloud.herokuapp.com request_id=b66caaee-880a-46a0-918b-e778a49334f4 fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:54.865321+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=timesheet-cloud.herokuapp.com request_id=d5af6aa7-0279-4f0e-a4cc-0f9e8682ec2f fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:55.158317+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=timesheet-cloud.herokuapp.com request_id=2d69f4b5-9015-48de-9314-c493703818d1 fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
This is likely to happen because Heroku does not detect any endpoint for your application (binded on port 3000 by default).
Heroku attributes your app a dynamic port, and put the port value on the env variable named $PORT.
Your app have to use the value specified by Heroku in this variable and listen for incoming connections on it, because that is where Heroku will forward connections.
The variable has to be read when the app starts:
https://help.heroku.com/PPBPA231/how-do-i-use-the-port-environment-variable-in-container-based-apps
You can check current env variables on your app using heroku run printenv
(I see you are using Viper, that should handle env variables. However they say in their documentation that when from env, it is case sensitive, maybe that could explain why it does not work for you: https://github.com/spf13/viper#working-with-environment-variables)
Thank you #Jonathan Muller. Solved!
GUI is running on https://timesheet-cloud.herokuapp.com.
On Heroku DB connection and PORT string should be read from the environment variables
DATABASE_URL
PORT
Updated was file timesheet.yaml.
BaseUrl in Axios is set to '' so Axios is using relative API URLs, which works. Fixed in file axiosSettings.js.
Before the command heroku run printenv returned:
panic: dial tcp 127.0.0.1:5432: connect: connection refused
Now I am getting:
Running printenv on ⬢ timesheet-cloud... up, run.1962 (Free)
Feb 15 16:22:34.186 [INFO] config file /timesheet.yaml
Feb 15 16:22:34.197 [INFO] connecting to DB postgres://user:hash#ec2-54-235-68-3.compute-1.amazonaws.com:5432/dbname
Feb 15 16:22:34.246 [INFO] connected to DB postgres://user:hash#ec2-54-235-68-3.compute-1.amazonaws.com:5432/dbname
Below is the Docker file:
FROM tomcat:7.0.90-jre7-alpine
ENV spring.profiles.active=dev
ENV CATALINA_OPTS=" -Dlogback.ContextSelector=JNDI"
#ADD builds/lib/ILCH-*.war $CATALINA_HOME/webapps/ilch.war
ADD heroku/catalina.sh /usr/local/tomcat/bin
RUN `chmod 777 /usr/local/tomcat/bin/catalina.sh`
Tomcat Server is started successfully per the below logs after container released:
heroku container:release web --app runningticker
The port assignment is good as I updated the server.xml inside the Catalina.sh before starting the server. (Last but one line in the docker file)
The requests to this application are not serving and I always see the logs code=H80 desc="Maintenance mode"
2018-09-22T19:38:08.446927+00:00 app[web.1]: INFO: Server startup in 5965 ms
2018-09-22T19:39:05.242821+00:00 heroku[router]: at=info code=H80 desc="Maintenance mode" method=GET path="/"
host=runningticker.herokuapp.com
request_id=e1cb4819-6bd9-4b04-8fc5-09c1bb2d7ad1 fwd="72.48.50.103"
dyno= connect= service= status=503 bytes= protocol=https
Expected to run the ROOT application of tomcat home page, but not.
What am I missing? Port binding while docker run? If so, how can I do this on Heroku?
If you wonder what's there in Catalina.sh this is the first line I added.
sed -i -e "s/8080/$PORT/" /usr/local/tomcat/conf/server.xml