[ONE-Dockerizing] onecc-docker using recent version only#9722
[ONE-Dockerizing] onecc-docker using recent version only#9722morumoru wants to merge 0 commit intoSamsung:masterfrom
Conversation
compiler/onecc-docker/Dockerfile
Outdated
| RUN apt update -y && \ | ||
| apt install -y \ | ||
| wget && \ | ||
| apt clean |
There was a problem hiding this comment.
| RUN apt update -y && \ | |
| apt install -y \ | |
| wget && \ | |
| apt clean | |
| RUN apt update -y && \ | |
| apt install -y wget && \ | |
| apt clean |
There was a problem hiding this comment.
I realized that this code don`t pass nacc format
I will check well before making pull request next time
compiler/onecc-docker/Dockerfile
Outdated
| apt clean | ||
| RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \ | ||
| apt-get install -y ./one-compiler_1.20.0_amd64.deb | ||
| ENTRYPOINT ["onecc"] No newline at end of file |
compiler/onecc-docker/onecc-docker
Outdated
| @@ -0,0 +1,84 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
it would be better to split this script and Docker files.
or can you explain the why Dockerfile and this file has close relation so that should be in one PR?
There was a problem hiding this comment.
Yes. Dockerfile is not related with this script and I'll remove Dockerfile on next PR
We want to show people complete Dockerfile that this script will make but It was wrong.
There was a problem hiding this comment.
We want to show people complete Dockerfile that this script will make but It was wrong.
In this case, you can use a draft PR. A Draft PR is not for merging, so you can show whole files you want. :)
jyoungyun
left a comment
There was a problem hiding this comment.
Please add usage message. :)
I have some trouble to run this script because of samsung network issue.
In this case, I got the below error message:
$ ./onecc-docker
403
rate limit exceeded
we can't get recent tag
In error situation, it would be good to write a detail message to make it easier for users to understand rather than simply printing a log. :)
compiler/onecc-docker/Dockerfile
Outdated
| @@ -0,0 +1,9 @@ | |||
| FROM ubuntu:18.04 | |||
There was a problem hiding this comment.
| FROM ubuntu:18.04 | |
| # Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| FROM ubuntu:18.04 |
All codes should contain this samsung copyright. :)
compiler/onecc-docker/Dockerfile
Outdated
| RUN apt update -y && \ | ||
| apt install -y \ | ||
| wget && \ | ||
| apt clean |
There was a problem hiding this comment.
| RUN apt update -y && \ | |
| apt install -y \ | |
| wget && \ | |
| apt clean | |
| RUN apt-get update && apt-get install -qqy --no-install-recommends \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* |
from https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
compiler/onecc-docker/Dockerfile
Outdated
| RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \ | ||
| apt-get install -y ./one-compiler_1.20.0_amd64.deb |
There was a problem hiding this comment.
| RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \ | |
| apt-get install -y ./one-compiler_1.20.0_amd64.deb | |
| RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb \ | |
| && apt-get install -y ./one-compiler_1.20.0_amd64.deb \ | |
| && rm -rf /var/lib/apt/lists/* |
compiler/onecc-docker/Dockerfile
Outdated
| apt clean | ||
| RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \ | ||
| apt-get install -y ./one-compiler_1.20.0_amd64.deb | ||
| ENTRYPOINT ["onecc"] No newline at end of file |
There was a problem hiding this comment.
| ENTRYPOINT ["onecc"] | |
| ENTRYPOINT ["onecc"] | |
compiler/onecc-docker/onecc-docker
Outdated
| @@ -0,0 +1,84 @@ | |||
| #!/usr/bin/env bash | |||
| ''''exec "python3" "onecc-docker" "$@" #''' | |||
There was a problem hiding this comment.
| ''''exec "python3" "onecc-docker" "$@" #''' | |
| ''''exec "python3" "$0" "$@" #''' |
compiler/onecc-docker/onecc-docker
Outdated
| @@ -0,0 +1,84 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
Please add samsung copyright.
|
Before uploading a code, please check the code convention using /cc @Samsung/ootpg |
compiler/onecc-docker/onecc-docker
Outdated
| def write_dockerfile(script_path,version) : | ||
|
|
||
| with open(f'{script_path}/Dockerfile', 'w', encoding='utf-8') as dockerfile: | ||
| dockerfile.write('FROM ubuntu:18.04 \n\n') | ||
| dockerfile.write('RUN apt update -y && \ \n') | ||
| dockerfile.write('\t apt install -y \ \n') | ||
| dockerfile.write('\t wget && \ \n') | ||
| dockerfile.write('\t apt clean \n') | ||
| dockerfile.write(f'RUN wget https://github.com/Samsung/ONE/releases/download/{version}/one-compiler_{version}_amd64.deb && \ \n') | ||
| dockerfile.write(f'\t apt-get install -y ./one-compiler_{version}_amd64.deb \n') | ||
| dockerfile.write('ENTRYPOINT ["onecc"]') |
There was a problem hiding this comment.
@jyoungyun
Currently, we check the latest version of "ONE" with github api and dynamically create a Dockerfile. Is this all right? Or is it better to commit one Dockerfile statically and use it continuously?
There was a problem hiding this comment.
This way is good to me.
Another way I thought was to create static Dockerfile with declaring version as a variable, and update the variable in bash command.
I think both ways are worth trying.
However, what about using the static Dockerfile with the fixed version like you implemented before?
There was a problem hiding this comment.
You can just parameterize the version with --build-arg option. Please see https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg for more detail.
|
Oh, thank you for code review. Is it better to commit push what has been modified through code review within the current PR #9722? Or should I put up a new PR? |
What about taking one PR is for |
|
Oh, thank you for your good opinion. As you advised, I will separate it into two PRs and upload it. |
compiler/onecc-docker/onecc-docker
Outdated
| onecc_version = subprocess.check_output("command -v onecc > /dev/null && echo $(onecc -v)", shell=True ,encoding='utf-8') | ||
| installed_onecc_version = onecc_version.split(' ')[2] |
There was a problem hiding this comment.
What if users don't have any version of one-compiler installed?
There was a problem hiding this comment.
I thought that command -v onecc will return empty when onecc is not installed
but when I tested now, subprocess return nonzero exit status so It makes error on that. I'll change my code to care about absent of one-compiler.
compiler/onecc-docker/onecc-docker
Outdated
| onecc_version = subprocess.check_output("command -v onecc > /dev/null && echo $(onecc -v)", shell=True ,encoding='utf-8') | ||
| installed_onecc_version = onecc_version.split(' ')[2] | ||
|
|
||
| script_path = re.sub("\n", "", os.popen('pwd').read()) |
There was a problem hiding this comment.
How about this one for better readability?
| script_path = re.sub("\n", "", os.popen('pwd').read()) | |
| script_path = os.path.realpath(__file__) |
compiler/onecc-docker/onecc-docker
Outdated
| print(response.reason) | ||
| print("we can't get recent tag") | ||
| exit(1) | ||
| else : |
There was a problem hiding this comment.
You don't need else syntax because above if always run exit.
| else : |
compiler/onecc-docker/onecc-docker
Outdated
| versions_json = json.loads(versions_str) | ||
| recent_version = versions_json[0]["name"] | ||
|
|
||
| if(recent_version == installed_onecc_version): |
There was a problem hiding this comment.
This if condition works in the python script?
| if(recent_version == installed_onecc_version): | |
| if recent_version == installed_onecc_version: |
There was a problem hiding this comment.
I missed to erase parparentheses on my if statement.
It works on python script when I tested, but I'll erase parparentheses
There was a problem hiding this comment.
Ah, you're right it works. FYI, I think parentheses should be used only if it improves readability or you actually want to change the order of expression calculation.
|
Do you have any plans for testing? |
Our current test plan is as follows.
Our plan is not perfect. @jyoungyun ,Can you give me a good opinion? |
At first, I thought it would be difficult to implement the test due to lack of time. However, even if the amount of implementation is reduced, implementing test codes seem to be a more complete way to write code. :) I wrote a draft code related to test for your convenience. I didn't test it yet because it takes a lot of time to compile at first. :) What about supporting test codes by referring #9731. |

introduce onecc-docker using recent version only
issue: #9721
Signed-off-by: Junsu Kim xofkdqkqh@naver.com