pine icon indicating copy to clipboard operation
pine copied to clipboard

Deploying on Railway

Open MattiaVerticchio opened this issue 3 years ago • 2 comments

Hi, first of all, thanks for developing Elm Fullstack! 😁

I’m trying to deploy the test config on Railway.app using the following Dockerfile:

FROM ubuntu:22.04

RUN apt update
RUN apt install -y curl unzip

# Download elm-fs
RUN curl --fail --location --output "/elm-fs.zip" "https://github.com/elm-fullstack/elm-fullstack/releases/download/v2022-09-15/elm-fullstack-bin-724de76b6c4d2f87e1e4df487964e2701cc8cef0-linux-x64.zip"

# Unzip and make executable
RUN unzip elm-fs.zip
RUN rm elm-fs.zip elm-fs.pdb
RUN chmod +x elm-fs

# Run test command
ENTRYPOINT [ "/bin/bash", "-l", "-c"]
CMD ["/elm-fs run-server --public-urls=https://elm-fullstack.up.railway.app --deploy=https://github.com/elm-fullstack/elm-fullstack/tree/8ce169c776160db7a035a8d3a7845341af11f871/implement/example-apps/docker-image-default-app"]

However, I’m getting this error output:

I got no path to a persistent store for the process. This process will not be persisted!
Loading app config to deploy...
This path looks like a URL into a remote git repository. Trying to load from there...
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'source')
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
at Pine.ZipArchive.ZipArchiveFromEntries(IReadOnlyDictionary`2 entries, CompressionLevel compressionLevel)
at Pine.CacheByFileName.GetOrUpdate(String fileName, Func`1 getNew)
at Pine.LoadFromGitHubOrGitLab.GetRepositoryFilesPartialForCommitDefault(GetRepositoryFilesPartialForCommitRequest request)
at Pine.LoadFromGitHubOrGitLab.LoadFromUrl(String sourceUrl, Func`2 getRepositoryFilesPartialForCommit)
at Pine.ProcessWithLog`2.<>c__DisplayClass12_0`1.<MapResult>b__0(ResultT result)
at Pine.ProcessWithLog`2.Continue[NewResultT](Func`2 continuation)
at Pine.ProcessWithLog`2.<>c__DisplayClass11_0`1.<Continue>b__0()
at Pine.ProcessWithLog`2.<>c__DisplayClass11_0`1.<Continue>b__0()
at Pine.ProcessWithLogExtension.LogToActions[LogEntryT,ResultT](ProcessWithLog`2 firstStep, Action`1 logAction)
at ElmFullstack.WebHost.BuildConfigurationFromArguments.BuildConfigurationZipArchiveFromPath(String sourcePath)
at ElmFullstack.Program.<>c__DisplayClass5_0.<AddRunServerCmd>b__1()
at McMaster.Extensions.CommandLineUtils.CommandLineApplicationExtensions.<>c__DisplayClass9_0.<OnExecute>b__0()
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at ElmFullstack.Program.<>c__DisplayClass4_0.<Main>g__executeAndGuideInCaseOfException|4()
at ElmFullstack.Program.Main(String[] args)

It’s the first time I use Elm Fullstack, Docker, and Railway, so I’m not sure if I’m doing everything correctly.

Is there something I’m doing wrong?

MattiaVerticchio avatar Sep 30 '22 08:09 MattiaVerticchio

Hello, thank you for sharing your experience!

I was able to repro this runtime exception here with the docker image you posted. Besides the base image, I don't see any problem in that dockerfile. The binaries from the zip-archive depend on ASP.NET core runtime, which is usually added by using an ASP.NET core docker image. Switching the base image to the one from the reference docker build at https://github.com/elm-fullstack/elm-fullstack/blob/81e61aaada9bf95ea16b5cb75c09cd2e5d0b3743/implement/Dockerfile#L11 was enough to fix the crash:

FROM mcr.microsoft.com/dotnet/aspnet:7.0.0-rc.1

Since you tried Ubuntu 22.04, I also tried an image based on Ubuntu 22.04, found at https://hub.docker.com/_/microsoft-dotnet-aspnet/

image

The crash also happens with that base image. I will look into why that is.

If a Debian-based image works for your app, using the mentioned image should be enough to fix it. I don't expect any differences when running on Railway.

Viir avatar Oct 01 '22 15:10 Viir

I fixed a bug in the program code that caused the ArgumentNullException we were seeing.

With the new version of Elm Fullstack, we see a more specific error for the Ubuntu 22.04 environment. The setup from the docker file with Ubuntu now leads to this error:

I got no path to a persistent store for the process. This process will not be persisted!
Loading app config to deploy...
This path looks like a URL into a remote git repository. Trying to load from there...
Unhandled exception. System.Exception: Failed to clone from 'https://github.com/elm-fullstack/elm-fullstack.git'
 ---> LibGit2Sharp.LibGit2SharpException: could not load ssl libraries
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in /_/LibGit2Sharp/Core/Proxy.cs:line 278
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in /_/LibGit2Sharp/Repository.cs:line 793   at Pine.LoadFromGitHubOrGitLab.GetRepositoryFilesPartialForCommitViaLibGitSharpCheckout(String cloneUrl, String commit)
   --- End of inner exception stack trace ---
   at Pine.LoadFromGitHubOrGitLab.GetRepositoryFilesPartialForCommitViaLibGitSharpCheckout(String cloneUrl, String commit)
   at Pine.ResultExtension.<>c__DisplayClass1_0`2.<FirstOkOrErrors>b__1(IImmutableList`1 previousErrors)
   at Pine.Result`2.Unpack[T](Func`2 fromErr, Func`2 fromOk)
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
   at Pine.LoadFromGitHubOrGitLab.<>c__DisplayClass10_0.<GetRepositoryFilesPartialForCommitDefault>b__0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Pine.LoadFromGitHubOrGitLab.<>c__DisplayClass10_0.<GetRepositoryFilesPartialForCommitDefault>b__1()
   at Pine.CacheByFileName.GetOrTryAdd(String fileName, Func`1 tryBuild)
   at Pine.LoadFromGitHubOrGitLab.GetRepositoryFilesPartialForCommitDefault(GetRepositoryFilesPartialForCommitRequest request)

So far, I don't know why the SSL dependency fails on Ubuntu-based docker images.

Regarding your application: Note that this crash also depends on using a URL in a git repository for deploying. The attempt to load from GitHub is caused by the value for the --deploy= option leading into github.com Deploying from a local directory instead avoids the crash.

Following is a dockerfile with this solution:

FROM mcr.microsoft.com/dotnet/aspnet:7.0.0-rc.1-jammy-amd64

RUN apt update
RUN apt install -y curl unzip
RUN apt install -y git

# Download elm-fs
RUN curl --fail --location --output "/elm-fs.zip" "https://github.com/elm-fullstack/elm-fullstack/releases/download/v2022-10-05/elm-fullstack-bin-cda8b8eee330749f499f55effc1c5eabc77e5480-linux-x64.zip"

# Unzip and make executable
RUN unzip elm-fs.zip
RUN rm elm-fs.zip elm-fs.pdb
RUN chmod +x elm-fs

WORKDIR /git-clone
RUN git  clone  https://github.com/elm-fullstack/elm-fullstack
WORKDIR /

# Run test command
ENTRYPOINT [ "/bin/bash", "-l", "-c"]
CMD ["/elm-fs run-server --public-urls=https://elm-fullstack.up.railway.app --deploy=/git-clone/elm-fullstack/implement/example-apps/docker-image-default-app"]

Viir avatar Oct 06 '22 10:10 Viir