-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial CI/CD workflow #5
base: main
Are you sure you want to change the base?
Conversation
b2f988c
to
a39d677
Compare
…ted grpc files to prettierignore
…(inspired by job in snowballr-api)
1c7d284
to
4a3b87e
Compare
39c03f5
to
3237bef
Compare
…bmodule is initialized in docker job
3237bef
to
380fba3
Compare
Probably we need to find another solution for the deployment, because if we regularly start new mock backends on the server without stopping and deleting the existing containers, we will run into space problems very quickly. I am open for suggestions. |
.dockerignore
Outdated
**/docker-compose* | ||
**/compose.y*ml | ||
**/Dockerfile* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we just remove them in the last pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are, as I said I generated this file and docker seems to be the opinion that these files should not be included, but as I said, I would integrate it. I will delete it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me like there is a lot in here that is not part of our project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there is a lot of stuff not included in our project. I didnt create this .dockerignore
on my own, but (as I wrote in the PR description) used docker init
as @Slartibartfass2 suggested. This command generated this file and the compose file and Dockerfile etc. based on our files and additional best practices. So imo it is no problem, that this file ignore more files per default than we have, because if we add files later it is more unlikely that we get problems because someone (probably me) forgot to add the files to this .dockerignore
compose.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why go for a compose file if we're only working with one container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I didn't create this compose file, it was completely generated by
docker init
- Imo, we should not delete it either, because it seems to me that on the one hand it is easier to start a container with a compose file and on the other hand it is not impossible that another container could come later or something and then you can simply extend it directly.
Basically, I understand that it seems pointless, but to be honest, I don't think this file needs to be maintained and therefore doesn't mean any effort, does it?
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "snowballr-mock-backend", | |||
"version": "1.0.0", | |||
"description": "A Mock Backend for the SnowballR Frontend Development", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is title-case a no-go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it is not a no-go, in my experience it's just very unusual for descriptions, especially of packages. But if you want to go with this title-case I can change it back, but the version should stay 0.1, as everything can still change in the mock backend (e.g. dynamically load data at the start will be introduced soon).
export const LOGGING_INTERCEPTOR: ServerInterceptor = function ( | ||
methodDescriptor: ServerMethodDefinition<any, any>, | ||
export const LOGGING_INTERCEPTOR: ServerInterceptor = function <RequestT, ResponseT>( | ||
methodDescriptor: ServerMethodDefinition<RequestT, ResponseT>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting choice. I am surprised it works, I didn't know you could just do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched for a solution of this problem of types for generic functions and the first solution was using Generics. Didnt know this either, but it works and seems a bit more elegant to. Or should I change it back and add a comment for the linter?
Dockerfile
Outdated
|
||
################################################################################ | ||
# Create a stage for installing production dependecies. | ||
FROM base as deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker warns about inconsistent casing of keywords. as
should probably be capitalized everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I corrected it.
with: | ||
submodules: "recursive" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we explicitly want to pull all submodules for linting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we dont need to, but I pull the submodule to use the custom "setup" workflow (with always generate the grpc stuff and therefore need the submodule). If it is in your opinion not good practice, I can delete it and dont use the "setup" workflow.
.github/workflows/deploy.yml
Outdated
|
||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
docker run -d --name snowballr-mock-backend -p 3001:3001 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on exposing both viable ports? (the grpc-web one and the native one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was, that it is not necessary, as this is the deployed mock backend and why should we use grpcui or grpcurl with this, but on the other hand, it shouldn't cause any problem to expose the other port, so I will add it.
.github/workflows/deploy.yml
Outdated
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
echo "StrictHostKeyChecking no" >> ~/.ssh/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this already part of the ssh command below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is, you are right (I must admit, I only copied this code and forgot to check, whether there are duplicate "lines"). I delete this line.
.github/workflows/deploy.yml
Outdated
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the missing push: true
intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i accidentally deleted this line.
Couldn't we use the |
…rnings in Dockerfile and delete Dockerfile and compose file from .dockerignore)
4b7a7e2
to
b134277
Compare
…000 and remove duplicate commands)
b134277
to
fbc2257
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick response. I guess you also didn't test the deploy workflow. Any ideas how we can properly test it or do you think it will work without any problems or we will see the errors when merging to main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there is a lot of stuff not included in our project. I didnt create this .dockerignore
on my own, but (as I wrote in the PR description) used docker init
as @Slartibartfass2 suggested. This command generated this file and the compose file and Dockerfile etc. based on our files and additional best practices. So imo it is no problem, that this file ignore more files per default than we have, because if we add files later it is more unlikely that we get problems because someone (probably me) forgot to add the files to this .dockerignore
.dockerignore
Outdated
**/docker-compose* | ||
**/compose.y*ml | ||
**/Dockerfile* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are, as I said I generated this file and docker seems to be the opinion that these files should not be included, but as I said, I would integrate it. I will delete it.
Dockerfile
Outdated
|
||
################################################################################ | ||
# Create a stage for installing production dependecies. | ||
FROM base as deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I corrected it.
compose.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I didn't create this compose file, it was completely generated by
docker init
- Imo, we should not delete it either, because it seems to me that on the one hand it is easier to start a container with a compose file and on the other hand it is not impossible that another container could come later or something and then you can simply extend it directly.
Basically, I understand that it seems pointless, but to be honest, I don't think this file needs to be maintained and therefore doesn't mean any effort, does it?
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "snowballr-mock-backend", | |||
"version": "1.0.0", | |||
"description": "A Mock Backend for the SnowballR Frontend Development", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it is not a no-go, in my experience it's just very unusual for descriptions, especially of packages. But if you want to go with this title-case I can change it back, but the version should stay 0.1, as everything can still change in the mock backend (e.g. dynamically load data at the start will be introduced soon).
export const LOGGING_INTERCEPTOR: ServerInterceptor = function ( | ||
methodDescriptor: ServerMethodDefinition<any, any>, | ||
export const LOGGING_INTERCEPTOR: ServerInterceptor = function <RequestT, ResponseT>( | ||
methodDescriptor: ServerMethodDefinition<RequestT, ResponseT>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched for a solution of this problem of types for generic functions and the first solution was using Generics. Didnt know this either, but it works and seems a bit more elegant to. Or should I change it back and add a comment for the linter?
.github/workflows/deploy.yml
Outdated
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i accidentally deleted this line.
with: | ||
submodules: "recursive" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we dont need to, but I pull the submodule to use the custom "setup" workflow (with always generate the grpc stuff and therefore need the submodule). If it is in your opinion not good practice, I can delete it and dont use the "setup" workflow.
.github/workflows/deploy.yml
Outdated
|
||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
docker run -d --name snowballr-mock-backend -p 3001:3001 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was, that it is not necessary, as this is the deployed mock backend and why should we use grpcui or grpcurl with this, but on the other hand, it shouldn't cause any problem to expose the other port, so I will add it.
.github/workflows/deploy.yml
Outdated
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
echo "StrictHostKeyChecking no" >> ~/.ssh/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is, you are right (I must admit, I only copied this code and forgot to check, whether there are duplicate "lines"). I delete this line.
Closes #3
What I have made
docker init
) for best practices