Skip to content

Deployment Sharing Session

Enrico Candino edited this page Mar 24, 2023 · 15 revisions

Deployment Sharing Session are specific Epinio session where someone share its screen while that person tries to install a specific Application and we discuss together how the User experience was and how it could have been improved.

2023-03-23

During the latest session we went through the Go and NodeJS samples from the Paketo Buildpacks repo.

They went well, and we just faced a small issue with an invalid Host Header with angular and vue, probably because of some development settings.

2023-03-09

Still working on the freeCodeCamp.

After a long build it finally succedeed but it failed during the export:

===> EXPORTING
Adding layer 'paketo-buildpacks/ca-certificates:helper'
Adding layer 'paketo-buildpacks/node-engine:node'
Adding layer 'paketo-buildpacks/npm-install:launch-modules'
Adding 1/1 app layer(s)
Adding layer 'buildpacksio/lifecycle:launcher'
Adding layer 'buildpacksio/lifecycle:config'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Saving freecodecamp...
*** Images (sha256:a12819d436c8208120efcf214b8ea0fbf9ca184647f47e28dc755b6f84dc1d0b):
      freecodecamp - HEAD https://index.docker.io/v2/library/freecodecamp/blobs/sha256:4870d14b5dfc063cf7887f8649fe7843443093eda6e225114b1122eed5ecf310: unexpected status code 401 Unauthorized (HEAD responses have no body, use GET for details)
ERROR: failed to export: failed to write image to the following tags: [freecodecamp: HEAD https://index.docker.io/v2/library/freecodecamp/blobs/sha256:4870d14b5dfc063cf7887f8649fe7843443093eda6e225114b1122eed5ecf310: unexpected status code 401 Unauthorized (HEAD responses have no body, use GET for details)]

We tried to build it locally without the docker container but we got this error and run out of time:

creator \
  -app=freeCodeCamp \
  -layers=freeCodeCamp/layers \
  -platform=freeCodeCamp \
  -report=layers/report.toml \
  -process-type=web \
  -skip-restore=false \
  -log-level=debug \
  freecodecamp

Warning: Platform requested deprecated API '0.3'
Warning: CNB_PLATFORM_API is unset; using Platform API version '0.3'
CNB_PLATFORM_API should be set to avoid breaking changes when upgrading the lifecycle
no stack metadata found at path '/cnb/stack.toml'
ERROR: failed to resolve inputs: -run-image is required when there is no stack metadata available

2023-03-02

We kept working on the freeCodeCamp app. We built and run it locally following the readme, and then we tried to build it with the Paketo Buildpack locally.

docker run -it \
  --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $(pwd):/workspace/source/app \
  -e BP_LOG_LEVEL=DEBUG \
  -e BP_NODE_VERSION=19.6.1 \
  -e NODE_VERBOSE=true \
  paketobuildpacks/builder:full
/cnb/lifecycle/creator \
  -app=/workspace/source/app \
  -uid=1000 \
  -gid=1000 \
  -layers=/layers \
  -platform=/workspace/source \
  -report=/layers/report.toml \
  -process-type=web \
  -skip-restore=false \
  freecodecamp

We had some issues due to the cached image (a bit old) that was not having the correct Node version in it.

When we finally built the source it failed at the end with

not finished Caching JavaScript and CSS webpack compilation - 37.986s
not finished Caching HTML renderer compilation - 3.194s
      
      npm ERR! Lifecycle script `build` failed with error: 
      npm ERR! Error: command failed 
      npm ERR!   in workspace: @freecodecamp/client@0.0.1 
      npm ERR!   at location: /workspace/source/app/client 
      ERROR: "build:client" exited with 1.
exit status 1
ERROR: failed to build: exit status 1

2023-02-23

We are trying to focus on deploying famous applications, one for each language: https://gist.github.com/kkaempf/b0206c5bc85f0a8e1547912775dbc236

We started with freeCodeCamp (Javascript).

We tried to push it without any other modification and we got

Warning: .env file not found. 
---------------------------------------------------- 
Please copy sample.env to .env 

You can ignore this warning if using a different way 
to setup this environment. 
----------------------------------------------------

We have seen that the .env file had an MONGOHQ_URL env var, so we deployed a MongoDB service, and we added the endpoint:

MONGOHQ_URL=mongodb://x62215c67064c3cac3413ad9c6536-mongodb.workspace.svc.cluster.local:27017/freecodecamp

While deploying again we suddendly lost the follow to the logs, and we were not able to read them anymore. The build took also a lot of time (+20m), so we wasted most of the hour just watching at logs.

At the end we got this error:

failed Building production JavaScript and CSS bundles - 198.928s
 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @freecodecamp/client@0.0.1
npm ERR!   at location: /workspace/source/app/client
ERROR: "build:client" exited with 1

Problems and possible solutions

Build time

Build time was incredibly long, and the error at the end frustrating.
Can we build it locally with the same workflow, and prevent some errors?

Bug: lost connection

During the staging we suddendly lost the connection, but we wasn't aware of it. Can we catch the error and return it to the user?

Bug: staging logs with --follow

Trying to catchup the logs again with epinio app logs --staging --follow freecode the logs were not complete (they were showing only the unpack-blob).

Improvement: staging logs with "step"

Sometimes the logs are "a lot". It will be nice to select one of the stage to filter out the pod/container:

epinio app logs --staging --stage [download-s3-blob, unpack-blob, buildpack] freecode

Samples

We have tried to deploy also a sample JS app from the Paketo samples (https://github.com/paketo-buildpacks/samples/tree/main/nodejs/vue-npm) and we were not able to. The app was deployed but not running.

/workspace/source/app/start.sh: 3: /workspace/source/app/start.sh: vue-cli-service: not found

2023-02-09

Deploy the Azure sample voting app: https://github.com/Azure-Samples/azure-voting-app-redis

It's a Python app, made with Flask.

We tried to push it and we had some problems with the dependencies. In the end we make it work adding the requirements.txt file, and adding the REDIS variable to our service instance.

We had also to add the REDIS_PWD, and we did it manually. It was connecting to the Redis instance, but then we were not able to reach it because of the issue of the fixed 8080 port.

2023-01-26

Deploy a OneTimeSecret instance: https://github.com/onetimesecret/onetimesecret

One-Time Secret

It's a Ruby app with a Redis db. It can be used to create a one-time secret link that can be viewed only once. A single-use URL.

After cloning it we tried to push it and we got an error

Paketo Buildpack for Bundle Install 0.6.3 
  Executing launch environment install process 
    Running 'bundle config --global clean true' 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
    Running 'bundle config --global path /layers/paketo-buildpacks_bundle-install/launch-gems' 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
    Running 'bundle config --global without development:test' 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
      /layers/paketo-buildpacks_bundler/bundler/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2. 
    Running 'bundle config --global cache_path --parseable' 
panic: runtime error: index out of range [1] with length 1 

goroutine 1 [running]: 
github.com/paketo-buildpacks/bundle-install.BundleInstallProcess.Execute({{0x1104880, 0xc0005a2500}, {{{0x1103e80, 0xc00000e018}, {{...}, {...}, {...}, {...}, {...}, {...}}, ...}}, ...}, ...) 
	/tmp/dup-dest3230150865/bundle_install_process.go:204 +0x1348 
github.com/paketo-buildpacks/bundle-install.Build.func1.3() 
	/tmp/dup-dest3230150865/build.go:213 +0x328 
github.com/paketo-buildpacks/packit/v2/chronos.Clock.Measure({0x11032a0?}, 0xc00069d098) 
	/home/runner/go/pkg/mod/github.com/paketo-buildpacks/packit/v2@v2.8.0/chronos/clock.go:21 +0x3f 
github.com/paketo-buildpacks/bundle-install.Build.func1({{{0xc0002a07e0, 0x20}, {0xc0002a0840, 0x23}, {0xc0004333e8, 0x5}, {0xc000438f80, 0x33}, {0xc000438f00, 0x38}, ...}, ...}) 
	/tmp/dup-dest3230150865/build.go:200 +0x1bba 
github.com/paketo-buildpacks/packit/v2.Build(0xc000340410, {0x0, 0x0, 0x18f38c0?}) 
	/home/runner/go/pkg/mod/github.com/paketo-buildpacks/packit/v2@v2.8.0/build.go:153 +0x758 
github.com/paketo-buildpacks/packit/v2.Run(0x1103e80?, 0xc00000e018?, {0x0?, 0x0, 0x0}) 
	/home/runner/go/pkg/mod/github.com/paketo-buildpacks/packit/v2@v2.8.0/run.go:31 +0x24e 
main.main() 
	/tmp/dup-dest3230150865/run/main.go:25 +0x391 
ERROR: failed to build: exit status 2 

We were not sure about the error, so we tried to follow the README and we did a bundle install --frozen and pushed again.
It worked but the app was not deployed successfully (crashloop).

We had a look at the logs (note: how do we check the logs of a crashing app?)

bundler: failed to load command: thin (/layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/bin/thin)
/layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/storable-0.8.9/lib/proc_source.rb:41:in `<top (required)>': uninitialized constant RubyToken (NameError)

class RubyToken::Token
      ^^^^^^^^^
Did you mean?  RubyLex
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/storable-0.8.9/lib/storable.rb:35:in `require'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/storable-0.8.9/lib/storable.rb:35:in `<class:Storable>'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/storable-0.8.9/lib/storable.rb:33:in `<top (required)>'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/sysinfo-0.7.3/lib/sysinfo.rb:2:in `require'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/sysinfo-0.7.3/lib/sysinfo.rb:2:in `<top (required)>'
    from /workspace/source/app/lib/onetime.rb:13:in `require'
    from /workspace/source/app/lib/onetime.rb:13:in `<top (required)>'
    from /workspace/source/app/lib/onetime/app/web.rb:2:in `require'
    from /workspace/source/app/lib/onetime/app/web.rb:2:in `<top (required)>'
    from /workspace/source/app/config.ru:17:in `require'
    from /workspace/source/app/config.ru:17:in `block in <main>'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/rack-2.1.4.1/lib/rack/builder.rb:71:in `instance_eval'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/rack-2.1.4.1/lib/rack/builder.rb:71:in `initialize'
    from /workspace/source/app/config.ru:1:in `new'
    from /workspace/source/app/config.ru:1:in `<main>'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/rack/adapter/loader.rb:33:in `eval'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/rack/adapter/loader.rb:33:in `load'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/thin/controllers/controller.rb:72:in `start'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/thin/runner.rb:203:in `run_command'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/lib/thin/runner.rb:159:in `run!'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/gems/thin-1.8.0/bin/thin:6:in `<top (required)>'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/bin/thin:25:in `load'
    from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.1.0/bin/thin:25:in `<top (required)>'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `load'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:23:in `run'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli.rb:491:in `exec'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli.rb:34:in `dispatch'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/cli.rb:28:in `start'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/exe/bundle:45:in `block in <top (required)>'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    from /layers/paketo-buildpacks_bundler/bundler/gems/bundler-2.4.4/exe/bundle:33:in `<top (required)>'
    from /layers/paketo-buildpacks_bundler/bundler/bin/_bundle:25:in `load'
    from /layers/paketo-buildpacks_bundler/bundler/bin/_bundle:25:in `<main>'
Stream closed EOF for workspace/ronetimesecret-3aeb5f1a75f4b40d87dc88558ce1ec334091f25c-d4qtl7v (ronetimesecret-3aeb5f1a75f4b40d87dc88558ce1ec334091f25c)

and after a quick search we have seen that the error was because of a deprecated dependency: https://github.com/onetimesecret/onetimesecret/issues/137

RubyToken deprecated in Ruby 2.7 -> RubyLex

We tried to use an older version of Ruby (epinio push -n onetimesecret -p . --env "BP_MRI_VERSION=2.6.*" but it's not available

buildpack failed to satisfy "ruby" dependency version constraint "2.6.*": no compatible versions on "io.buildpacks.stacks.bionic" stack. Supported versions are: [2.7.6, 2.7.7, 3.0.4, 3.0.5, 3.1.2, 3.1.3] 

Since we really wanted to deploy this application we tried to use a Docker image (epinio push -n onetimesecret --container-image-url dismantl/onetimesecret). It worked! Some logs:

Generating OTS secret: 1a7f3e236111c4c025272c73d2cd6c0e45b5ccb3                                                                                                                                                                           
Starting redis-server: redis-server.  

Unfortunately we have tried to access it, but the app was actually running on a different port (7143). We tried to see if at least it was working as expected and we used the port-forward to access it from localhost:

epinio app port-forward onetimesecret 8088:7143

We wanted to try to use a service, and we have created it with epinio service create redis-dev myredis. Unfortunately the Docker image we tried was using an embedded Redis, so we tried another one (chrisipa/onetimesecret):

/var/lib/onetime/vendor/bundle/ruby/2.1.0/gems/redis-2.2.2/lib/redis/client.rb:236:in `rescue in establish_connection': Connection refused - Unable to connect to Redis on 127.0.0.1:7179 (Errno::ECONNREFUSED) 

Ok, so we tried to manually set the internal service endpoint:

epinio push -n onetimesecret --container-image-url chrisipa/onetimesecret \
  --env "OTS_REDIS_URI=redis://xbe737f7c936b454da33f586d0166-redis-master.workspace.svc.cluster.local:6379/0?timeout=10&thread_safe=false&logging=false"

and we got the AUTH error

NOAUTH Authentication required. (RuntimeError) 

We setup the authentication inside the uri manually:

epinio push -n onetimesecret --container-image-url chrisipa/onetimesecret \
  --env "OTS_REDIS_URI=redis://:3o8KhkvpJ9@xbe737f7c936b454da33f586d0166-redis-master.workspace.svc.cluster.local:6379/0?timeout=10&thread_safe=false&logging=false"

and it worked! We also checked the Redis with kubectl run --image=goodsmileduck/redis-cli -it --rm redis -n workspace

Outcome

  • Provide a default app chart that can provide the customisation of the PORT (https://github.com/epinio/epinio/issues/1792)
  • The port-forward for services would be nice to have (https://github.com/epinio/epinio/issues/2037)
  • Not sure if the logs of a crashing app are available
  • Provide a way for the user to use/bind existing app variables with service and/or existing variables (i.e.: the OTS_REDIS_URI is hardcoded, and the value needs to be joined from an external env var, and a secret in the /configurations/myredis/redis-password)

2023-01-19

The goal was to try to create and deploy a simple Node application, and bind it to a MongoDB service.

Simple Node.js+MongoDB

A simple main.js file was working, but when we added npm with some dependencies then it started failing.

2023/01/19 09:56:06 readlink /workspace/source/app/node_modules: invalid argument                                                                                                                                                        
ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_npm-install/launch-modules/exec.d/0-setup-symlinks': exit status 1
Stream closed EOF for workspace/rsample-8151325dcdbae9e0ff95f9f9658432dbedfdb209-77486d8bbn84jx (rsample-8151325dcdbae9e0ff95f9f9658432dbedfdb209)    

We had a look at the doc: https://paketo.io/docs/howto/nodejs/, we tried adding the Procfile, the BP_KEEP_FILES env var, and adding a build script to the package.json file.

We then got a random issue that forced us to create a different application:

β”‚ 2023/01/19 10:03:35 EpinioServer: "msg"="ERROR" "error"="application 'sample' already exists" "requestId"="475cde0b-6ca0-46f6-ab66-2dd6df7af8e3" "origin"="/api/v1/namespaces/workspace/applications" "error"="application 'sample' alrea β”‚
β”‚ dy exists"                                                                                                                                                                                                                                β”‚
β”‚ 2023/01/19 10:03:35 EpinioServer: "msg"="Error" "error"="application 'sample' already exists"                                                                                                                                             β”‚
β”‚ 2023/01/19 10:03:37 EpinioServer: "msg"="ERROR" "error"="an error occurred while uninstalling the release. original install error: services \"rsample-8151325dcdbae9e0ff95f9f9658432dbedfdb209\" not found: uninstall: Release not loaded β”‚
β”‚ : sample-8151325dcdbae9e0ff95f9f9658432dbedfdb209: release: not found" "requestId"="eb8e3b2d-65ab-490d-83ea-1a95e9f06319" "origin"="/api/v1/namespaces/workspace/applications/sample/deploy" "error"="an error occurred while uninstallin β”‚
β”‚ g the release. original install error: services \"rsample-8151325dcdbae9e0ff95f9f9658432dbedfdb209\" not found: uninstall: Release not loaded: sample-8151325dcdbae9e0ff95f9f9658432dbedfdb209: release: not found"                       β”‚
β”‚ 2023/01/19 10:03:37 EpinioServer: "msg"="Error" "error"="an error occurred while uninstalling the release. original install error: services \"rsample-8151325dcdbae9e0ff95f9f9658432dbedfdb209\" not found: uninstall: Release not loaded β”‚
β”‚ : sample-8151325dcdbae9e0ff95f9f9658432dbedfdb209: release: not found"   

In the end this package.json was enough (no Procfile, no BP_KEEP_FILES env var):

{
  "name": "samplenode",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "node main.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mongodb": "4.13"
  }
}

We bound a mongodb service but we were not able to connect to it:

Server running at http://127.0.0.1:8080/
MongoServerSelectionError: Client network socket disconnected before secure TLS connection was established
    at Timeout._onTimeout (/layers/paketo-buildpacks_npm-install/launch-modules/node_modules/mongodb/lib/sdam/topology.js:285:38)
    at listOnTimeout (node:internal/timers:564:17)
    at process.processTimers (node:internal/timers:507:7) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) {
      'x62215c67064c3cac3413ad9c6536-mongodb.workspace.svc.cluster.local:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: null,
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}

We then run out of time, but we have thought that it could be useful to have the same port-forward for the services, and be able to connect to them from your local machine.

2022-11-24

We tried to deploy [mastodon](https://github.com/mastodon/mastodon

Mastodon

Mastodon is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.

Tech Stack

  • Ruby on Rails powers the REST API and other web pages
  • React.js and Redux are used for the dynamic parts of the interface
  • Node.js powers the streaming API

Requirements:

  • PostgreSQL 9.5+
  • Redis 4+
  • Ruby 2.6+
  • Node.js 14+

Deployment

We cloned the repository and tried to push it. It initially failed because of a too recent Ruby version, and so we pushed again spoecifying the --env "BP_MRI_VERSION=2.7.5" flag.

It failed again a couple of times for two missing environment variables (OTP_SECRET and SECRET_KEY_BASE) that were supposed to be generated with a rake secret command.

Note: it seems strange that an env var like this is required at build time.. (?)

After setting the two env var to something "random" we encountered another issue regarding the Node version used, that was un unstable one, and also another warning about the Ruby version:

(Warning: you are using an unstable release of Node.js (v19.0.1)
---
warning: parser/current is loading parser/ruby27, which recognizes2.7.6-compliant syntax, but you are running 2.7.5

so we used the "BP_MRI_VERSION=2.7.6" and "BP_NODE_VERSION=18.12.1" environment variables.

This was not enough because of an error during the Paketo Buildpack for Rails Assets 0.8.0 phase:

Paketo Buildpack for Rails Assets 0.8.0 
  Executing build process 
    Running 'bundle exec rails assets:precompile assets:clean' 
      yarn install v1.22.19 
      [1/6] Validating package.json... 
      [2/6] Resolving packages... 
      success Already up-to-date. 
      Done in 0.65s. 
      I, [2022-11-24T10:35:48.580938 #2904]  INFO -- : Writing /workspace/source/app/public/assets/doorkeeper/admin/application-a644908e7bab54fb749be0f59fb64a7480bbf9c4c2b79d4a65791cb7ab4d8730.css 
      I, [2022-11-24T10:35:48.581361 #2904]  INFO -- : Writing /workspace/source/app/public/assets/doorkeeper/admin/application-a644908e7bab54fb749be0f59fb64a7480bbf9c4c2b79d4a65791cb7ab4d8730.css.gz 
      I, [2022-11-24T10:35:48.593411 #2904]  INFO -- : Writing /workspace/source/app/public/assets/doorkeeper/application-c93dac2ad9d65e3393e0e2c958481e86ef7a5e5b0f6ce406842a7b99b25a4850.css 
      I, [2022-11-24T10:35:48.593596 #2904]  INFO -- : Writing /workspace/source/app/public/assets/doorkeeper/application-c93dac2ad9d65e3393e0e2c958481e86ef7a5e5b0f6ce406842a7b99b25a4850.css.gz 
      I, [2022-11-24T10:35:48.595460 #2904]  INFO -- : Writing /workspace/source/app/public/assets/pghero/favicon-db10337a56c45eb43c22ff5019546b520fa22c7281d4d385f235cbca67ed26bb.png 
      I, [2022-11-24T10:35:48.885728 #2904]  INFO -- : Writing /workspace/source/app/public/assets/pghero/application-a60bf0a452ed064fef3594cf52a4c998712da7c76150f890f4eaa644f59671e4.js 
      I, [2022-11-24T10:35:48.885884 #2904]  INFO -- : Writing /workspace/source/app/public/assets/pghero/application-a60bf0a452ed064fef3594cf52a4c998712da7c76150f890f4eaa644f59671e4.js.gz 
      I, [2022-11-24T10:35:48.894877 #2904]  INFO -- : Writing /workspace/source/app/public/assets/pghero/application-c31338f656687c1d733bb0f48d40acd076e24060f3dcff83b34870e4ccc2789d.css 
      I, [2022-11-24T10:35:48.895050 #2904]  INFO -- : Writing /workspace/source/app/public/assets/pghero/application-c31338f656687c1d733bb0f48d40acd076e24060f3dcff83b34870e4ccc2789d.css.gz 
      Compiling... 
      Compilation failed: 
      /layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/cli.js:93 
                                throw err; 
                                ^ 
 
      TypeError: Cannot read properties of undefined (reading 'compress') 
          at Object.<anonymous> (/workspace/source/app/config/webpack/development.js:31:35) 
          at Module._compile (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) 
          at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) 
          at Module.load (node:internal/modules/cjs/loader:1037:32) 
          at Module._load (node:internal/modules/cjs/loader:878:12) 
          at Module.require (node:internal/modules/cjs/loader:1061:19) 
          at require (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) 
          at WEBPACK_OPTIONS (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13) 
          at requireConfig (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6) 
          at /layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17 
          at Array.forEach (<anonymous>) 
          at module.exports (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15) 
          at /layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/cli.js:71:45 
          at Object.parse (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/node_modules/yargs/yargs.js:576:18) 
          at /layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/cli.js:49:8 
          at Object.<anonymous> (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack-cli/bin/cli.js:366:3) 
          at Module._compile (node:internal/modules/cjs/loader:1159:14) 
          at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) 
          at Module.load (node:internal/modules/cjs/loader:1037:32) 
          at Module._load (node:internal/modules/cjs/loader:878:12) 
          at Module.require (node:internal/modules/cjs/loader:1061:19) 
          at require (node:internal/modules/cjs/helpers:103:18) 
          at Object.<anonymous> (/layers/paketo-buildpacks_yarn-install/build-modules/node_modules/webpack/bin/webpack.js:156:2) 
          at Module._compile (node:internal/modules/cjs/loader:1159:14) 
          at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) 
          at Module.load (node:internal/modules/cjs/loader:1037:32) 
          at Module._load (node:internal/modules/cjs/loader:878:12) 
          at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) 
          at node:internal/main/run_main_module:23:47 
 
      Node.js v18.12.1 
 
failed to execute bundle exec output: 
 
error: exit status 1 
ERROR: failed to build: exit status 1 

Locally the yarn install succeeded, so we tried to run the same bundle exec rails assets:precompile assets:clean command, but the Ruby version was not compatible, and it took time trying to install it.

Managed with brew:

brew install ruby@3.0
brew link ruby@3.0
-> % ruby --version
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]
-> % bundle exec rails assets:precompile assets:clean
bundler: command not found: rails
Install missing gem executables with `bundle install`
brew install postgresql # needed for the 'bundle install'
gem install pg -- --with-pg-config=/home/linuxbrew/.linuxbrew/opt/postgresql@14/bin/pg_config
bundle install

Then a shared lib was missing:

-> % RAILS_ENV=production bundle exec rails assets:precompile assets:clean
rails aborted!
LoadError: libicudata.so.71: cannot open shared object file: No such file or directory - /home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.so

With some tricks I managed to copy the needed libs and pass through the bundle exec locally, and it worked. Still failing on the Builpacks.

sudo cp /home/linuxbrew/.linuxbrew/lib/libicudata.so.71 /usr/lib64/
sudo cp /home/linuxbrew/.linuxbrew/lib/libicuuc.so.71 /usr/lib64/
sudo cp /home/linuxbrew/.linuxbrew/lib/libicui18n.so.71 /usr/lib64/
sudo cp /home/linuxbrew/.linuxbrew/lib/libicuio.so.71 /usr/lib64/
-> % secret_key_base=mysecret OTP_SECRET=mysecret RAILS_ENV=production bundle exec rails assets:precompile assets:clean 
/home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/gems/rexml-3.2.5/lib/rexml/document.rb:40: warning: already initialized constant REXML::Document::DECLARATION
/home/linuxbrew/.linuxbrew/Cellar/ruby@3.0/3.0.4_1/lib/ruby/gems/3.0.0/gems/rexml-3.2.5/lib/rexml/document.rb:40: warning: previous definition of DECLARATION was here
/home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/gems/rexml-3.2.5/lib/rexml/xpath.rb:12: warning: already initialized constant REXML::XPath::EMPTY_HASH
/home/linuxbrew/.linuxbrew/Cellar/ruby@3.0/3.0.4_1/lib/ruby/gems/3.0.0/gems/rexml-3.2.5/lib/rexml/xpath.rb:12: warning: previous definition of EMPTY_HASH was here
yarn install v1.22.17
[1/6] Validating package.json...
[2/6] Resolving packages...
[3/6] Fetching packages...
[4/6] Linking dependencies...
warning Workspaces can only be enabled in private projects.
[5/6] Building fresh packages...
[6/6] Cleaning modules...
Done in 5.78s.
Compiling...
Compiled all packs in /home/enrico/Development/SUSE/mastodon/mastodon/public/packs

Probably the best thing is to try to use the same builder also locally.

2022-11-10

We tried to deploy postfacto

Postfacto

Postfacto is a rails application that relies on a Mysql database. The Postfacto repository contains both the API and the frontend application which are located in sub directories. We decided to try the API.

The GitHub form was very smooth. One downside was the field to specify the repository owner is labeled "user/organization", and instinctively we interpreted as "owner/repository". Then we easily navigate through the form. Unfortunately Buildpack wasn't able to detect sub directory project and we couldn't specify which directory map to which application from the UI so we decided to switch to the command line

git clone https://github.com/pivotal/postfacto.git
cd postfacto/api
epinio push --path . --name postfacto

Due to the outdated Ruby dependencies, the epinio command failed and buildpack complained that the Ruby version specified in the Gemfile.lock (2.7.3) wasn't supported anymore.

So we had to specify the environment variable "BP_MRI_VERSION=2.7.5"

epinio push --path . --name postfacto --env "BP_MRI_VERSION=2.7.5" --env "RAILS_ENV=development"

Overriding the ruby version solved it but then we struggle with the following error, but none of us are familiar with Rails so we decided to stop the experiment but I would expected that we need to specify the command to run in a Procfile

πŸ•ž  [stage-workspace-postfa-dd1ec4663245fa2501b38662f3ff7a8c2bdvmwkt] buildpack   Executing build process
πŸ•ž  [stage-workspace-postfa-dd1ec4663245fa2501b38662f3ff7a8c2bdvmwkt] buildpack     Running 'bundle exec rails assets:precompile assets:clean'
πŸ•ž  [stage-workspace-postfa-dd1ec4663245fa2501b38662f3ff7a8c2bdvmwkt] buildpack       rails aborted!
πŸ•ž  [stage-workspace-postfa-dd1ec4663245fa2501b38662f3ff7a8c2bdvmwkt] buildpack       ActiveRecord::AdapterNotSpecified: The `production` database is not configured for the `production` environment.

2022-10-26

We try to deploy this VotingApp used as example by acorn here We focused only in the worker repo

Voting App

  1. Need permissions for Gitlab to clone; then git clone git@gitlab.com:voting-application/worker.git
  2. We tried to deploy the go directory
  3. Attempting to deploy as it is brought this error:
πŸ•ž  [stage-workspace-vote-g-b1a9d466777e783ad98abca7fef9128491dtv7rt] buildpack ERROR: failed to export: default process type 'web' not present in list [worker] 
  1. Created Proc file with web: worker and worked but found later this second error:
πŸ•ž  [rvote-go-app-2-7d6cabcc7d9f5ced549f4ed55837ec4e075d4a2f-7cktgts] rvote-go-app-2-7d6cabcc7d9f5ced549f4ed55837ec4e075d4a2f Waiting for Redis dial tcp: lookup redis on 10.43.0.10:53: no such host 
  1. Updated Redis address main.go with x48fe64940d55cc02a2129d72b4e0-redis-master.workspace.svc.cluster.local
    Got 1 time error (ok after retrying):
  error pushing app to server: can't deploy app: Internal Server Error: Get "https://objects.githubusercontent.com/github-production-release-asset-2e65be/424524901/6349ae9d-791d-452c-8242-30d9a3a6f796?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221027%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221027T131631Z&X-Amz-Expires=300&X-Amz-Signature=fee2d1f9bc264f7942ef55348eb5a6808443b4e20c94072369c6a4dd9468c99f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=424524901&response-content-disposition=attachment%3B%20filename%3Depinio-application-0.1.22.tgz&response-content-type=application%2Foctet-stream": EOF
  1. After we got Authentication required error and run out of time:
πŸ•ž  [rvote-go-app-3-103cd7e5d959868dfc3419adaf3146d5edeaf2e1-bdglchh] rvote-go-app-3-103cd7e5d959868dfc3419adaf3146d5edeaf2e1 Waiting for Redis NOAUTH Authentication required. 

Takeaway

Perhaps we could create a manifest file that could read the custom service needed and deploy it automatically.

2022-10-20

Before going with a new application, we first went back on the previous experiment to deploy mirrorbits. Last week we faced two issues

Mirrorbits

1. Wrong command:

When running epinio push --name mirrorbits, the deployment failed because buildpack couldn't detect the command to execute. We solved this by creating a file named Procfile with the following content

web: mirrorbits daemon --config mirrorbits.conf

A proposed documentation update has been done here

2. Wrong configuration file

Mirrorbits needs a configuration to work. While we had it locally in our git repository, we needed a extra step to provide it to Epinio. We've managed it by running epinio push --name mirrorbits --env BP_KEEP_FILES="mirrorbits.conf"

Geekos

For the second application, we were interested to test an application using an external service such as a database. We decided to pick https://github.com/SUSE/geekos-backend as it's a Rails application using Mongodb

Deploying a Mongodb instance was a breeze even thought we deploy the latest version of Mongo instead of the one specified in Geekos requirements.

Trying to push the code of the geekos-backend it failed for a missing configuration key:

Figaro::MissingKeys: Missing required configuration keys: ["geekos_mongodb_server"] 

We tried to push again the application specifying the environment variable as the internal MongoDB service host

epinio push --name geekos --env geekos_mongodb_server=xe96f583337c6c3d229e9230eb0dd-mongodb.workspace.svc.cluster.local

this failed again for a different reason:

Sprockets::FileNotFound: couldn't find file 'graphiql/rails/application.css'

This seems an issue related for some files that is not kept during the build. We tried providing the BP_KEEP_FILES env var but it didn't worked.

2022-10-13

Mirrorbits

B