oci-arm-host-capacity icon indicating copy to clipboard operation
oci-arm-host-capacity copied to clipboard

Add env OCI_DISPLAY_NAME to set display name

Open hassegawa opened this issue 3 years ago • 13 comments

Add env OCI_DISPLAY_NAME to set display name

hassegawa avatar Jan 26 '22 03:01 hassegawa

I created a docker image with your code

https://hub.docker.com/r/hassegawa/machine

hassegawa avatar Jan 26 '22 03:01 hassegawa

Hi, could you please share Dockerfile?

hitrov avatar Jan 26 '22 11:01 hitrov

As for the instance name, it’s better to implement through a setter instead of argument: by changing the arguments/their order we can ruin those who will watch YouTube or read Medium :) I’ll do this later, maybe, thank you

hitrov avatar Jan 26 '22 11:01 hitrov

…or just simple getter which will fallback with a default value if env var is not set

hitrov avatar Jan 26 '22 11:01 hitrov

…or just simple getter which will fallback with a default value if env var is not set

index.php

getenv('OCI_DISPLAY_NAME') ?: 'instance-' . date('Ymd-Hi'),

hassegawa avatar Jan 26 '22 17:01 hassegawa

Hi, could you please share Dockerfile?

  • https://github.com/hassegawa/oracle-tf
    • change line 17:
      • git clone https://github.com/hassegawa/oci-arm-host-capacity.git && \

Dockerfile with build per layer for build performance

https://github.com/hassegawa/oracle-tf/tree/performance


github action

https://github.com/hassegawa/oci-arm-host-capacity/commit/4eb053a31291d6fea400ba267e883e984b14b85b

hassegawa avatar Jan 26 '22 17:01 hassegawa

@hassegawa Please check that your Docker container's run.sh file permission is missing the execution bit. I have confirmed this ↓

/bin/sh: 1: ./run.sh: Permission denied

I have tested latest tag (maybe now equal hassegawa/machine:0.1.12).

Thanks.

falconws avatar Jan 31 '22 17:01 falconws

@hassegawa Please check that your Docker container's run.sh file permission is missing the execution bit. I have confirmed this ↓

/bin/sh: 1: ./run.sh: Permission denied

I have tested latest tag (maybe now equal hassegawa/machine:0.1.12).

Thanks.

'latest' and 0.1.12 are same: latest x 0.1.12

hassegawa avatar Feb 03 '22 16:02 hassegawa

@hassegawa Please check that your Docker container's run.sh file permission is missing the execution bit. I have confirmed this ↓

/bin/sh: 1: ./run.sh: Permission denied

I have tested latest tag (maybe now equal hassegawa/machine:0.1.12).

Thanks.

Can you try again? 0.1.13 or latest

latest x 0.1.12

hassegawa avatar Feb 03 '22 17:02 hassegawa

@hassegawa I tested your docker image, it works nicely :). My command:

docker run --rm -d \
    -v $(pwd)/.env:/app/oci-arm-host-capacity/.env \
    -v $(pwd)/key.pem:/app/oci-arm-host-capacity/key.pem \
    hassegawa/machine

I also use relative path ./key.pem in my .env file, it still works 😄

Maybe introduce RETRY_DELAY_TIME env to adjust the sleep time?

jackblk avatar Feb 17 '22 04:02 jackblk

By the way, I created a Dockerfile using alpine, the image size is very small ~190MB.

FROM composer:2

RUN apk add --no-cache jq~=1.6
WORKDIR /app/oci-arm-host-capacity

COPY ./oci-arm-host-capacity /app/oci-arm-host-capacity

RUN chmod +x run.sh \
    && cd /app/oci-arm-host-capacity && \
    composer update && \
    composer install

ENTRYPOINT [ "sh", "run.sh" ]

jq is not working with it yet because php will return some deprecated messages: Deprecated: Function openssl_free_key() is deprecated in /app/oci-arm-host-capacity/vendor/hitrov/oci-api-php-request-sign/src/Hitrov/OCI/Signer.php on line 115

However I think this approach produces a better image, easier to maintain.

jackblk avatar Feb 17 '22 07:02 jackblk

By the way, I created a Dockerfile using alpine, the image size is very small ~190MB.

FROM composer:2

RUN apk add --no-cache jq~=1.6
WORKDIR /app/oci-arm-host-capacity

COPY ./oci-arm-host-capacity /app/oci-arm-host-capacity

RUN chmod +x run.sh \
    && cd /app/oci-arm-host-capacity && \
    composer update && \
    composer install

ENTRYPOINT [ "sh", "run.sh" ]

jq is not working with it yet because php will return some deprecated messages: Deprecated: Function openssl_free_key() is deprecated in /app/oci-arm-host-capacity/vendor/hitrov/oci-api-php-request-sign/src/Hitrov/OCI/Signer.php on line 115

However I think this approach produces a better image, easier to maintain.

we cam try remove this function:

PHP 8 deprecates openssl_free_key (actually openssl_pkey_free which it aliases) and automatically destroys the key instance when it goes out of scope.

hassegawa avatar Feb 19 '22 02:02 hassegawa

@hassegawa I tested your docker image, it works nicely :). My command:

docker run --rm -d \
    -v $(pwd)/.env:/app/oci-arm-host-capacity/.env \
    -v $(pwd)/key.pem:/app/oci-arm-host-capacity/key.pem \
    hassegawa/machine

I also use relative path ./key.pem in my .env file, it still works 😄

Maybe introduce RETRY_DELAY_TIME env to adjust the sleep time?

To set RETRY_DELAY_TIME = 5 minutes, TAG >= v0.1.14

docker run --rm -d \
-e RETRY_DELAY_TIME=5 \
-v $(pwd)/.env:/app/oci-arm-host-capacity/.env \
-v $(pwd)/key.pem:/app/oci-arm-host-capacity/key.pem \
hassegawa/machine
  • RETRY_DELAY_TIME default is 10 minutes

hassegawa avatar Feb 19 '22 03:02 hassegawa