DEV Community

Discussion on: GitLab CI/CD example with a dockerized ReactJS App 🚀

Collapse
 
duongnguyen1216 profile image
Dương Nguyễn • Edited

Hey, thank you very much for very detailed example.
I did it successfully and I found some point

  • The final .gitlab-ci.yml file, at deploy state, port should be 3005
  • $SSH_PRIVATE_KEY is string, not a file so we can't use chmod , I've replaced by this line
  stage: deploy
  image: kroniak/ssh-client
  before_script:
    - echo "deploying app"
  script:
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > key.pem
    - chmod 400 key.pem
    - ssh -o StrictHostKeyChecking=no -i key.pem root@$PROD_SERVER_IP ...
    - ssh -o StrictHostKeyChecking=no -i key.pem root@$PROD_SERVER_IP ...
    - ssh -o StrictHostKeyChecking=no -i key.pem root@$PROD_SERVER_IP ...
Enter fullscreen mode Exit fullscreen mode

I used EC2 Ubuntu 18.04 Server.

Thank you again <3

Collapse
 
nickty profile image
nickty

Please share with us the updated code

Collapse
 
swetank01 profile image
swetank soni

I just got tricked with that error. Thanks for the fix.🥳

Collapse
 
tomasbalaz profile image
Tomas Balaz • Edited

You can set your private key gitlab variable as file and then you don't have to create key.pem file

Collapse
 
christianmontero profile image
Christian Montero

oh! sorry for that mistake bro! 😔
but thanks for sharing your solution this will help other devs! 💪
and thank you for reading bro! 👍