Docker compose simple routing for Mysql router

    version: '3.1'
services:
  Mysql:
    image:
      mysql-router:latest
    hostname: mysql-router
    environment:
      MYSQL_PASSWORD: 123456
      MYSQL_HOST: 192.168.1.1
      MYSQL_PORT: xx
      MYSQL_USER: xxx

I would like to deploy a Mysql router with a docker-compose file on 192.168.1.2 and I will like to make it route to another MySQL router, the MYSQL_HOST is the destination (192.168.1.1). I get the error message said that the 192.168.1.1 contain MySQL InnoDB cluster but schema doesn’t exist, I understand the solution can be added/adopt group replication deployment but I have no idea why there is a cluster because all I want to do is just simple routing from 192.168.1.2 to 192.168.1.1. I appreciate if someone have an idea about what go wring here

installing – How do I avoid overwriting the .htaccess file when I use the Compose command?

On my new Drupal 9 website, I customized the .htaccess file and the robots.txt file

I don’t want its files to be overwritten when updating with Composer.

I added the lines below in my composer.json file but the .htassess file is overwritten every time. What’s wrong with my code ? Thank you

"extra": {
    "drupal-scaffold": {
        "locations": {
            "web-root": "./"
        },
        "file-mapping": {
            "[web-root]/.htaccess": false,
            "[web-root]/robots.txt": false
        }
    },
...

Kafka Broker Runs locally via docker compose but fails in kubernetes with near identical config

Kafka broker runs beautifully when running locally via docker-compose.

version: "3"
services:
  zookeeper:
    image: 'bitnami/zookeeper:latest'
    ports:
      - '2181:2181'
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    image: 'bitnami/kafka:latest'
    ports:
      - '9092:9092'
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    depends_on:
      - zookeeper

When running via kubernetes though

apiVersion: v1
kind: Service
metadata:
  name: zevrant-kafka-zookeeper-service
spec:
  ports:
    - port: 443
      targetPort: 2181
  selector:
    app: zevrant-kafka-zookeeper-service
---
apiVersion: v1
kind: Service
metadata:
  name: zevrant-kafka-service
spec:
  type: NodePort
  ports:Connection to node -1 (/<IP_ADDRESS>:30129) could not be established. Broker may not be available.
    - port: 443
      targetPort: 9092
      nodePort: 30129
  selector:
    app: zevrant-kafka-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: zevrant-kafka-zookeeper-service-deployment
  labels:
    app: zevrant-kafka-zookeeper-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: zevrant-kafka-zookeeper-service
  template:
    metadata:
      labels:
        app: zevrant-kafka-zookeeper-service
    spec:
      volumes:
        - name: zookeeper-data
          nfs:
            server: <IP_ADDRESS>
            path: /zookeeper
      imagePullSecrets:
        - name: regcred
      nodeSelector:
        architecture: amd64
      containers:
        - name: zevrant-kafka-zookeeper-service
          image: bitnami/zookeeper:3.7.0
          env:
            - name: ALLOW_ANONYMOUS_LOGIN
              value: "yes"
          ports:
            - containerPort: 2181
          volumeMounts:
            - name: zookeeper-data
              mountPath: /bitnami/zookeeper
        - name: zevrant-kafka-zookeper-ui-service
          image: elkozmon/zoonavigator:1.1.0
          ports:
            - containerPort: 9000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: zevrant-kafka-service-daemonset
  labels:
    app: zevrant-kafka-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: zevrant-kafka-service
  template:
    metadata:
      labels:
        app: zevrant-kafka-service
    spec:
      volumes:
        - name: kafka-storage
          hostPath:
            path: /opt/kafka/dev/
      imagePullSecrets:
        - name: regcred
      nodeSelector:
        architecture: amd64
      containers:
        - name: zevrant-kafka-broker-service
          image: bitnami/kafka:2.8.0
          volumeMounts:
            - name: kafka-storage
              mountPath: /bitnami/kafka
          ports:
            - containerPort: 9092
          env:
            - name: ALLOW_PLAINTEXT_LISTENER
              value: "yes"
            - name: KAFKA_CFG_ZOOKEEPER_CONNECT
              value: "zevrant-kafka-zookeeper-service:443"
            - name: KAFKA_BROKER_ID
              value: "1"
            - name: KAFKA_CFG_LISTENERS
              value: "PLAINTEXT://0.0.0.0:9092"
            - name: KAFKA_CFG_ADVERTISED_LISTENERS
              value: "PLAINTEXT://<IP_ADDRESS>:30129"

The broker starts but repeatedly spams the error

INFO (Admin Manager on Broker 1): Error processing create topic request CreatableTopic(name='zevrant-video-stream', numPartitions=1, replicationFactor=1, assignments=(), configs=()) (kafka.server.ZkAdminManager)

I used the same command on both clusters to create the topic aside from the connection details and in both cases I ran the command from inside the running broker container.

Locally

kafka-topics.sh --create --topic zevrant-video-stream --zookeeper localhost:2181 --partitions 1 --replication-factor 1 --config retention.ms=86400000

Kubernetes

kafka-topics.sh --create --topic zevrant-video-stream --zookeeper zevrant-kafka-zookeeper-service:443 --partitions 1 --replication-factor 1 --config retention.ms=86400000

I’m not really sure why this works in one place and not the other.

Attempting to connect a producer to the kubernetes broker i receive

Connection to node -1 (/<IP_ADDRESS>:30129) could not be established. Broker may not be available.

When querying zookeeper for broker information, zookeeper shows the broker as connected

zkCli.sh get /brokers/ids/1


{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT"},"endpoints":("PLAINTEXT://<IP_ADDRESS>:9092"),"jmx_port":-1,"features":{},"host":"<IP_ADDRESS>","timestamp":"1622398259745","port":9092,"version":5}

What would cause the broker to connected, online, but unavailable?

Docker Compose Unable to obtain connection from database (jdbc:postgresql://db:5432/postgres) for user ‘postgres’: The connection attempt failed

The Problem:

I am using Docker Compose to create two containers: One with a Postgres database on it and the other with Flyway on it. The goal is to use Flyway to migrate scripts to the Postgres database instance. When I run docker-compose up I get the following error:

Unable to obtain connection from database (jdbc:postgresql://db:5432/) for user 'luke_skywalker': The connection attempt failed.

My code is below and thank you for your help!

Here is my docker-compose.yml:

version: "3.7"

services:
  postgres_db:
    image: postgres:11.3
    container_name: postgres_database
    restart: always
    # map host port to default postgres port of the contianer; note host port was randomly chose from ports that are unassinged
    environment:
      POSTGRES_USER: ${postgres_user}
      POSTGRES_PASSWORD: ${postgres_password}
    ports:
      - 11102:5432

  flyway_migration:
    #https://github.com/flyway/flyway-docker
    image: flyway/flyway
    container_name: flyway
    environment:
      FLYWAY_PASSWORD: ${postgres_password}
      FLYWAY_USER:  ${postgres_user}
    volumes:
        #create flyway supported volume in the container that has our migration scripts; https://github.com/flyway/flyway-docker
      - .migration_scripts:/flyway/sql
    #change back to 60
    command: -url=jdbc:postgresql://db:5432/ -connectRetries=1 migrate -X
    depends_on:
      - postgres_db

Here is the full error message:

Attaching to postgres_database, flyway
postgres_database   | 2021-05-27 03:23:59.359 UTC (1) LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_database   | 2021-05-27 03:23:59.359 UTC (1) LOG:  listening on IPv6 address "::", port 5432
postgres_database   | 2021-05-27 03:23:59.365 UTC (1) LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_database   | 2021-05-27 03:23:59.385 UTC (23) LOG:  database system was shut down at 2021-05-27 03:19:05 UTC
postgres_database   | 2021-05-27 03:23:59.389 UTC (1) LOG:  database system is ready to accept connections
flyway              | DEBUG: Loading config file: /flyway/conf/flyway.conf
flyway              | DEBUG: Unable to load config file: /flyway/flyway.conf
flyway              | DEBUG: Unable to load config file: /flyway/flyway.conf
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/jna-4.5.2.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/msal4j-1.10.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/mssql-jdbc-9.2.1.jre8.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/jna-platform-4.5.2.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/postgresql-42.2.19.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/hsqldb-2.5.1.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/derbyclient-10.15.2.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/mysql-connector-java-8.0.24.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/derbytools-10.15.2.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/jaybird-jdk18-3.0.10.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/google-cloud-spanner-jdbc-2.0.2.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/aws-secretsmanager-jdbc-1.0.6.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/derbyshared-10.15.2.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/snowflake-jdbc-3.13.1.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/jtds-1.3.1.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/derby-10.15.2.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/mariadb-java-client-2.7.2.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/google-cloud-storage-1.113.13.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/sqlite-jdbc-3.34.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/ojdbc8-19.6.0.0.jar
flyway              | DEBUG: Adding location to classpath: /flyway/drivers/h2-1.4.200.jar
flyway              | DEBUG: Using configuration:
flyway              | DEBUG: flyway.connectRetries -> 1
flyway              | DEBUG: flyway.jarDirs -> /flyway/jars
flyway              | DEBUG: flyway.locations -> filesystem:sql
flyway              | DEBUG: flyway.password -> *************
flyway              | DEBUG: flyway.url -> jdbc:postgresql://db:5432/postgres
flyway              | DEBUG: flyway.user -> luke_skywalker
flyway              | DEBUG: Multiple databases found that handle url 'jdbc:postgresql://db:5432/postgres': CockroachDB, PostgreSQL
flyway              | DEBUG: Scanning for classpath resources at 'classpath:db/callback' ...
flyway              | DEBUG: Determining location urls for classpath:db/callback using ClassLoader java.net.URLClassLoader@18be83e4 ...
flyway              | DEBUG: Unable to resolve location classpath:db/callback.
flyway              | Flyway Community Edition 7.9.1 by Redgate
flyway              | DEBUG: AWS SDK available: false
flyway              | DEBUG: Google Cloud Storage available: false
flyway              | DEBUG: Scanning for filesystem resources at 'sql'
flyway              | DEBUG: Scanning for resources in path: sql (sql)
flyway              | DEBUG: Found filesystem resource: sql/V1__initial.sql
flyway              | WARNING: Connection error: The connection attempt failed. (Caused by db) Retrying in 1 sec...
flyway              | ERROR: Unexpected error
flyway              | org.flywaydb.core.internal.exception.FlywaySqlException:
flyway              | Unable to obtain connection from database (jdbc:postgresql://db:5432/postgres) for user 'luke_skywalker': The connection attempt failed.
flyway              | ----------------------------------------------------------------------------------------------------------------------------------------
flyway              | SQL State  : 08001
flyway              | Error Code : 0
flyway              | Message    : The connection attempt failed.
flyway              |
flyway              |   at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:68)
flyway              |   at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:68)
flyway              |   at org.flywaydb.core.Flyway.execute(Flyway.java:510)
flyway              |   at org.flywaydb.core.Flyway.migrate(Flyway.java:170)
flyway              |   at org.flywaydb.commandline.Main.executeOperation(Main.java:227)
flyway              |   at org.flywaydb.commandline.Main.main(Main.java:148)
flyway              | Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
flyway              |   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
flyway              |   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
flyway              |   at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
flyway              |   at org.postgresql.Driver.makeConnection(Driver.java:465)
flyway              |   at org.postgresql.Driver.connect(Driver.java:264)
flyway              |   at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:263)
flyway              |   at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnection(DriverDataSource.java:227)
flyway              |   at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:54)
flyway              |   ... 5 more
flyway              | Caused by: java.net.UnknownHostException: db
flyway              |   at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
flyway              |   at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
flyway              |   at java.base/java.net.Socket.connect(Unknown Source)
flyway              |   at org.postgresql.core.PGStream.createSocket(PGStream.java:231)
flyway              |   at org.postgresql.core.PGStream.<init>(PGStream.java:95)
flyway              |   at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98)
flyway              |   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
flyway              |   ... 12 more
flyway exited with code 1

docker compose – How to host CouchDB with Fauxton (_utils) at a non-root location using traefik as a reverse proxy

Here is a solution that I got working:

#
# docker-compose.yml
#
version: '3.7'

volumes:
  db-data:
  cache-data:

services:
  #
  # reverse-proxy - application ingress
  #
  reverse-proxy:
    image: 'traefik:v2.4.8' # latest as of 2021-05-11
    ports:
      # http "web" traffic
      - '80:80'
      # https "web-secure" traffic
      - '443:443'
      # the "reverse-proxy"s web ui (enabled by --api.insecure=true)
      - '8080:8080'
    volumes:
      # allow traefik to listen docker events
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
      # mount our certs where the "provider.file.certs" can find them
      - './certs:/opt/certs'
    command:
      # available log levels are DEBUG, INFO, WARN, ERROR, FATAL, PANIC
      - '--log.level=ERROR'
      # provide traefik
      - '--api.insecure=true'
      # we are using docker ;-)
      - '--providers.docker'
      # # prevent a bunch of extra routers in the gui
      - '--providers.docker.exposedbydefault=false'
      # make our development certs available
      - '--providers.file.filename=/opt/certs/certs.toml'
      # incoming http "web" traffic
      - '--entrypoints.web.address=:80'
      # incoming https "web-secure" traffic
      - '--entrypoints.web-secure.address=:443'

  #
  # db - CouchDB Database Service
  #
  db:
    build:
      context: '.'
      dockerfile: './db/Dockerfile'
      args:
        - 'APPLICATION_ID'
        - 'AUTH_SECRET'
    depends_on:
      - 'reverse-proxy'
    ports:
      - '5984:5984'
    expose:
      - '5984'
    volumes:
      - 'db-data:/opt/couchdb/data'
      - './db/bin:/opt/db/bin'
    environment:
      - 'APPLICATION_ID'
      - 'AUTH_SECRET'
      - 'COUCHDB_USER'
      - 'COUCHDB_PASSWORD'
      - 'COUCHDB=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@db:5984'
    labels:
      - 'traefik.enable=true'
      # service db-service
      - 'traefik.http.services.db-service.loadbalancer.server.port=5984'
      # middleware db-stripper - strips '^/db' from requests
      - 'traefik.http.middlewares.db-stripper.stripprefix.prefixes=/db'
      # router db-https (db only listens on https)
      - 'traefik.http.routers.db-https.service=db-service'
      - 'traefik.http.routers.db-https.entrypoints=web-secure'
      - 'traefik.http.routers.db-https.rule=PathPrefix(`/db/`)'
      - 'traefik.http.routers.db-https.tls=true'
      - 'traefik.http.routers.db-https.middlewares=db-stripper'

Please note that you will need the trailing ‘/’ on the _utils url, like this `https://127.0.0.1/db/_utils/’

And thanks to @ceremcem for pointing me in the right direction to solve it in my world 😉

android – Shared Activity with Compose in Kotlin Multiplatform project

I have a problem with setting up an activity that resides in shared code in a KMM project and uses Jetpack Compose. When the activity is in Android source (/app) this works fine. But I’d like to publish a shared (/common) library without any application.

As an example I forked a great minimal KMM+Compose project: https://github.com/cyberhenoch/PeopleInSpace :

  • added the compose activity (SharedActivity) to the shared code
  • updated the dependencies in shared code androidMain

It compiles fine but at runtime I get:

Process: com.surrus.peopleinspace, PID: 4067
java.lang.NoSuchMethodError: No static method setContent$default(Landroidx/activity/ComponentActivity;Landroidx/compose/runtime/CompositionContext;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
in class Landroidx/activity/compose/ComponentActivityKt; or its super
classes (declaration of
‘androidx.activity.compose.ComponentActivityKt’ appears in
/data/app/com.surrus.peopleinspace-8P35Dcwzn9_G-xN9YdwFrA==/base.apk)
at com.surrus.android.SharedActivity.onCreate(SharedActivity.kt:12)

I tried to add the options described here https://developer.android.com/jetpack/compose/setup#configure_gradle but

  • not all can be added to the common module (kotlinOptions?)
  • in the original project they are not required and it works perfectly good
  • after adding several of them in different combinations it does not even compile (exception: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/serialization/DescriptorSerializerPlugin
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    )

What should I do to make it work? Any help would be appreciated.

android – Jetpack Compose – Problem with BottomSheetDialogFragment and ViewTreeLifecycleOwner

After updating the Jetpack Compose library to beta01, I’m not able to show DialogFragment or BottomSheetDialogFragment.
Looks like ViewTreeLifecycleOwner cannot be found in my activity anymore. Also, I tried a couple of possible solutions but there are not any success.

The view in fragment is inflated with:

 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(
                R.layout.fragment_full_screen_layout, container, false
        ).apply {
            findViewById<ComposeView>(R.id.compose_view).setContent {...}

and dialog fragment is showing with:

DialogFragmentExample.newInstance().show(supportFragmentManager, null)

Does anyone have a similar problem? Please, any suggestion would be welcome.

Stacktracke:

java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@409dd5d(MainActivity)
        at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:214)
        at androidx.compose.ui.platform.WindowRecomposer_androidKt.access$createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:1)
        at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$LifecycleAware$1.createRecomposer(WindowRecomposer.android.kt:98)
        at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:151)
        at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:199)
        at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:177)
        at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:222)

How to compose a very simple equasion

I am feeling a bit embarassed by looking at the complexity of other questions, but I struggle with math and I need to start somewhere, right?

The problem: I have a petrol car on which it would be possible to install a cheaper fuel alternative (LPG). However, this comes with a price.

What is the formula to calculate the amount of Kilometers after which the installation of that system is gives an advantage ? That is, the cost of the system is totally covered by the saving of LPG instead of petrol.

Some hypothetical data:

  • LPG fuel system: 2000$

  • LPG cost for 100km: 8$

  • Petrol cost for 100km: 15$

Any idea? Thanks!

css – How to customize the placement of compose in Gmail

I have Reading Pane enabled for Right of inbox, and that is slightly better, but what I need is to have the compose window over the inbox instead of below or over the reading pane.

My current layout
Current Gmail layout

Desired layout
Desired Gmail layout

The goal is to have the compose (reply) next to the reading instead of over it. I’ve been popping it out into a new window to move it, but then if I click on the reading window it goes behind. It seems like there should be a way to move the compose.

I suspect this is may require some custom CSS/JavaScript, and I’m OK with that. If so, please point me in the right direction.

post processing – How do you compose the price for the end product if it needs more then usual amount of retouching?

If you shoot a session, where the end product will have much exposed skin (face/body), how do you compose the price for the end product? Do you have fixed prices? Or do you calculate retouching separately from the whole post-processing?

I’m new in this business and would very like to know opinions of those who makes photos for life.

A variant appearing to me as logical, is:

  • client pays for the shooting on the hour basis, like hours amount X hour price,
  • client pays pays for the end product depending on how many images should be delivered, like amount of delivered images X average price for one completely retouched and post-processed image, because of retouching of each image could take different amount of time.

So the price formula would be like b hours X c $ (for shooting) + m images X n $ (for retouching/post-processing).