Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Mar 28 22:43
    StanBright starred hanami/hanami
  • Mar 28 20:47
  • Mar 27 14:04
    jodosha edited #1032
  • Mar 27 13:25
    jodosha synchronize #1032
  • Mar 27 13:25

    jodosha on hanami-router-2-alpha2

    Integrate `hanami-router` `v2.0… Use actions from slices' contai… Enable rack_monitor and Rack mi… and 7 more (compare)

  • Mar 27 13:01

    mereghost on hanami-relation

    Create Hanami::Relation object … (compare)

  • Mar 26 23:19
    jodosha synchronize #1032
  • Mar 26 23:19

    jodosha on hanami-router-2-alpha2

    Fix rubocop offenses (compare)

  • Mar 26 23:08
    jodosha review_requested #1032
  • Mar 26 23:08
    jodosha review_requested #1032
  • Mar 26 23:04
    jodosha synchronize #1032
  • Mar 26 23:04

    jodosha on hanami-router-2-alpha2

    Remove unnecessary args passed … (compare)

  • Mar 26 23:03
    jodosha synchronize #1032
  • Mar 26 23:03

    jodosha on hanami-router-2-alpha2

    Fix the signature of `Hanami::A… (compare)

  • Mar 26 22:54
    jodosha synchronize #1032
  • Mar 26 22:54

    jodosha on hanami-router-2-alpha2

    Make `Hanami::Application::Rout… (compare)

  • Mar 26 22:50
    jodosha synchronize #1032
  • Mar 26 22:50

    jodosha on hanami-router-2-alpha2

    Remove `hanami-api` dependency Introducing `Hanami::Applicatio… (compare)

  • Mar 26 16:15
    DeadByElpy starred hanami/hanami
  • Mar 26 01:52
    cabgfx starred hanami/hanami
Surya Poojary
@Surya-risingsun
Guys I don't know Rspec or BDD
Can I still start with hanami
Sebastjan Hribar
@sebastjan-hribar
@poojx I use minitest myself. Just specify it when creating a new project: https://guides.hanamirb.org/command-line/project/#testing-framework
Sebastjan Hribar
@sebastjan-hribar
A word of caution, yesterday I had to recreate my gemfile.lock and the updates seem to affect pluralization of contact_person. I created the table contact_persons, but the now broken tests complain about not finding contact_people :smile: I'm aware of this plural form, however it doesn't seem natural for this context. Anyway, I'm changing it to simply contacts what I should have done in the first place.
Sebastjan Hribar
@sebastjan-hribar
Auto generated tests for minitest report deprecated warning for global use of must_equal and global use of must_include which will fail in Minitest 6. I'm using the latest version 5.13.0. Where should I check if this is already being reported?
Kai Kuchenbecker
@kaikuchn
I think here https://github.com/hanami/hanami/issues would be appropriate
Jeff Dickey
@jdickey
Hey, folks: has anyone successfully used Semaphore CI to build a Dockerised Hanami app? I'm running into a database-access problem that has me profoundly confused
Kai Kuchenbecker
@kaikuchn
No, I'm using CircleCI. However, I may still be able to help you out
Jeff Dickey
@jdickey

Thanks, @kaikuchn. I'm having a problem getting Semaphore's Postgres service to connect with my app (which has already passed non-Docker tests) using their standard Postgres service, which is activated by the command step sem-service start postgres. The CI log indicates that it starts successfully, and a subsequent sem-service status postgres confirms this. Their (Rails+Postgres) doc at https://docs.semaphoreci.com/article/73-ruby#database-configuration indicates that setting the DATABASE_URL environment variable in the Dockerfile (which Hanami also uses for the same purpose, in the same format) to, e.g., postgresql://postgres:@0.0.0.0/semaphore_hanami_poc should Just Work. However, running bin/hanami db drop acts as though Postgres isn't running.

From the log:

Step 11/15 : RUN bin/hanami db drop || true

 ---> Running in 291c9f4b9efb

dropdb: could not connect to database template1: could not connect to server: Connection refused

        Is the server running on host "0.0.0.0" and accepting

        TCP/IP connections on port 5432?

/usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:99:in `block in call_db_command'

        /usr/local/lib/ruby/2.6.0/open3.rb:219:in `popen_run'

        /usr/local/lib/ruby/2.6.0/open3.rb:101:in `popen3'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:98:in `call_db_command'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:44:in `drop'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator.rb:295:in `drop'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator.rb:76:in `drop'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/db/drop.rb:26:in `drop_database'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/db/drop.rb:17:in `call'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/command.rb:85:in `call'

        /usr/local/bundle/gems/hanami-cli-0.3.1/lib/hanami/cli.rb:57:in `call'

        /usr/local/bundle/gems/hanami-1.3.2/bin/hanami:6:in `<top (required)>'

        bin/hanami:29:in `load'

        bin/hanami:29:in `<main>'

The Dockerfile continues on to the next step (because we ORed true with the previous one), and encounters the identical error when it attempts to run bin/hanami db create

Ideas?

Kai Kuchenbecker
@kaikuchn
In their example on managing databases they don't actually connect to the DB from within another container but from within the same "command" which I assume is run in a container.
They also say that services are local to such a block... Can you maybe show the relevant part of the semaphore config file?
Is maybe this the workflow you want to have? (I.e., instead of using sem-services start and link containers)
Jeff Dickey
@jdickey
@kaikuchn I've put the two pipeline configs up at https://gist.github.com/jdickey/0bd4113e018befb97d62bf7db369bb5b
  • docker-build.yml is the one that's failing; it runs after semaphore.yml;
  • semaphore.yml runs CI tests against a non-Dockerised copy of the app
Kai Kuchenbecker
@kaikuchn
So you try to setup the database when building the Docker image. Is that right?
Also, I don't see you specifying the DATABASE_URL in the docker-build.yml?
Jeff Dickey
@jdickey
Yes; before I started using Semaphore, I'd built images locally using a close variant of the current Dockerfile and had essentially followed the docs for setting up DATABASE_URL and the other variables in the .env files
No, it's in the Dockerfile, which really should be in that Gist. Hang on and I'll add it
Updated; Gist ordering means it's now the second file in the Gist
Kai Kuchenbecker
@kaikuchn
Why aren't you preparing the DB when starting the container instead of when building it?
The DB isn't part of the image, so there's no use of running it during build time unless you're never leaving that context (i.e., you build where you run).
Jeff Dickey
@jdickey
Good question; I don't really have an answer for that beyond "it worked the first time (locally)"
Kai Kuchenbecker
@kaikuchn
Yeah, because it's the same context. But you really should write an entrypoint.sh script instead and do that there.
Jeff Dickey
@jdickey
true, it's not part of the image (and d'oh!). Yeah, and entrypoint.sh makes sense; always be learning. Thanks; I think I've got enough ammo for the next footgun :D
Kai Kuchenbecker
@kaikuchn
Here's a basic one:
#!/bin/bash

set -Eeuo pipefail

# do stuff

exec "$@"
Jeff Dickey
@jdickey
right; I'll figure out the 'do stuff'. Thanks again
Kai Kuchenbecker
@kaikuchn
That's basically line 21 and 22 in your dockerfile.
don't forget to add ENTRYPOINT ["/docker-entrypoint.sh"] after adding the script. Otherwise he'll just execute command without passing it to your script.
I guess I'd then add a different step to your pipeline (i.e., another yml file?) where you use the built image to run your tests, or whatever you wanted to do, by specifying it in the containers section.
Jeff Dickey
@jdickey
Right; that's in the plan but I was just trying to recreate my deploy-to-k8s-from-locally-built-crap flow first. Running staging-level tests is in the plan. I'm almost getting buyers' remorse from taking on all this docker+k8s+dog-knows-what for a small team; we're not Google scale, but we have had problems matching environments when hand-deploying
there's a ginormous market opportunity for whoever finds the sensible middle ground on this
Kai Kuchenbecker
@kaikuchn
Yeah, I feel ya. k8s is awesome once everythings running. But getting there in a reproducible manner takes time.
Jeff Dickey
@jdickey
I first learned CI/CD when I was part of a large-ish company (150+ devs, 50+ dedicated ops people) and we had single-button deploys; I just misunderestimated how much work it took for one or two folks to get there
Thanks again
Kai Kuchenbecker
@kaikuchn
Oh one other thing you could try is adding --network bridge to the docker build call.

The docker docs are a little thin on this flag.. API 1.25 says

Sets the networking mode for the run commands during build. Supported standard values are: bridge, host, none, and container:<name|id>. Any other value is taken as a custom network's name to which this container should connect to.

docker build --help says

--network string Set the networking mode for the RUN instructions during build (default "default")

Jeff Dickey
@jdickey
yeah, that makes sense, too, and it's a cheap thrill. But I thought bridge was the default
Kai Kuchenbecker
@kaikuchn
So maybe bridge which I'd have thought was the default, isn't?
Jeff Dickey
@jdickey
oops; nope; I'll give it a try
Kai Kuchenbecker
@kaikuchn
My guess is that the docs are wrong and bridge is actually the default..
Otherwise how can you pull packages etc?
A sanity check I like to perform when I cannot establish a connection is this:
service="0.0.0.0/5432"; (timeout 1 bash -c "cat < /dev/null > /dev/tcp/$service" && echo "Success opening remote port") || echo "Could not connect"
This just checks whether a port is open without needing to install special networking tools.
Jeff Dickey
@jdickey
Right; that's a good one. I'll swipe that :grinning:
Sebastjan Hribar
@sebastjan-hribar

We're currently setting up the internationalization project wide and I found these resources: https://www.bounga.org/ruby/2016/10/08/using-i18n-with-hanami/ and https://github.com/ippachi/hanami-i18n

Since there is still no updates hanami/hanami#610 we'll go with the above gem. Can we tie the locale to a setting entity so admins could change the locale per each end user company?

Jeff Dickey
@jdickey
@kaikuchn Well, --network bridge had no discernible effect; on to the entrypoint
Kai Kuchenbecker
@kaikuchn
@jdickey who knows how semaphore makes the service available to you, probably service endpoints just aren't accessible for the docker daemon.. So entrypoint is a good way to just not fight that particular battle.
Jeff Dickey
@jdickey
Makes sense; I'll give it a try and ping their support if I don't get it in a day or so. Thanks for all your help
Kai Kuchenbecker
@kaikuchn
Good luck. Always happy to help.
Paweł Świątkowski
@katafrakt
@sebastjan-hribar I guess you need to set appropriate I18n.locale = locale_from_setting before every action, but it's definitely doable.