I have just recently started to work at a company as a Jr. UI Engineer (I am a Sr.UX UI Designer and have experience with Front-End JS Technologies, wanted to take this role as a challenge, and learn more) when I saw what GitLab and DevOps can do, it blew my mind away, and I added DevOps to my to-learn list. I personally did not know the DevOps technology got so good over the years, and automated. I remember the FTP Zilla days and just using GitHub etc.
Here are some of my questions but before I begin to ask questions, I humbly thank you in advance if you decide to give me some directions and knowledge.
I will try to be as detailed as I can be.
Technology I am planning to use: GitLab (Private), Docker, NPM (Private), AWS Beanstalk for full apps (Node, React, Express, EC2, S3, DynamoDB, etc.), EC2 for UI Libraries with StoryBook build (React, React Native, Electron, etc.)
So with that in mind:
How can I deploy to AWS EC2 via GitLab?
I hear lots of Docker talk around, but to be perfectly honest I kinda have some idea what it does, but not entirely. I am not even sure if I need it or not.
On merge to development, staging and master I want StoryBook to build and I want to deploy the build to the AWS EC2.
giblab-ci.yml file on storybook-build job:
build storybook:
stage: storybook
script:
- npm run storybook-build
only:
- master
- stage
- dev
The storybook spits out a storybook-static folder, an index.html, some js and CSS files, etc.
I have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY added to my GitLab as variables, and the key has super admin access.
So I would need to take this build and deploy it into EC2, right? But how? Maybe the Docker is playing a role here?
How can I register my NPM Package via GitLab and semantic versioning on merge to the master branch?
I have created an NPM Token, added it to the GitLab CI/CD variables as NPM_TOKEN
I also have my project ID added to the GitLab CI/CD variables as CI_PROJECT_ID
gitlab-ci.yml file on build job:
build:
stage: build
script:
- npm run build
- npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- echo '//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${NPM_TOKEN}'>.npmrc
- npm publish
artifacts:
paths:
- build/
only:
- master
I get an error:
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://registry.npmjs.org/@organization/package-name - You must be logged in to publish packages.
Is there any way I can automate the project creation on AWS via GitLab or any other tech?
For example, whenever I am working on a new project, I could just automate the project creation with templates, prepopulated variables added to correct places, super admin added, etc.
Thank you so much in advance!