Showing posts with label push. Show all posts
Showing posts with label push. Show all posts

Saturday, November 16, 2019

Images, Containers and Docker Registry

This tutorial shows how to create images and containers and push to hub.docker.com registry. GitHub repo is at https://github.com/nikola-bodrozic/Docker-ReactJS

Simple Build on Linux

Apache web server no Dockerfile, $(pwd) prints path to current folder

docker run -d --name apa -e TZ=UTC -p 8080:80 -v $(pwd)/html/:/var/www/html/ ubuntu/apache2

Development Build

docker build -t reactapp:1.0 .
docker run -p 3000:3000 \ 
       --env REACT_APP_BASE_URL=localhost \ 
       --name react-app reactapp:1.0
docker logs -f YOUR_CONTAINER_SHA

Prod build & push to registry

Create empty private image repo at DOCKER_HUB_USERNAME/REPO_NAME

The repo should be visible in browser at https://hub.docker.com/repository/docker/DOCKER_HUB_USERNAME/REPO_NAME

For production you need to set env variable in Dockerfile-prod not in docker run. Here's how
RUN REACT_APP_BASE_URL=example.com yarn build

build, run and push to registry

docker run -d \
           -p 80:80 \
           --name react-app-prod DOCKER_HUB_USERNAME/REPO_NAME:1.0

docker build -t DOCKER_HUB_USERNAME/REPO_NAME:1.0 \
             -f Dockerfile-prod .

docker login

docker push DOCKER_HUB_USERNAME/REPO_NAME:1.0
DOCKER_HUB_USERNAME/REPO_NAME:1.0

Tuesday, September 29, 2015

Git Clone and Push Using SSH with Passphrase

Open console and type

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/user_name/.ssh/id_rsa):<return>
Enter passphrase (empty for no passphrase):<type passphrase>
Enter same passphrase again:<type passphrase>
Your identification has been saved in /c/Users/user_name/.ssh/id_rsa.
Your public key has been saved in /c/Users/user_name/.ssh/id_rsa.pub.
The key fingerprint is:
**:**:**:**:**:** user_name@COMPUTERNAME

Your public key is at c:/Users/user_name/.ssh in file id_rsa.pub. Add the public key to your bitbucket account.

$ git clone git@bitbucket.org:folder_name/project_name.git
Cloning into project_name...
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is **:**:**:**:**:**.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.167' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/user_name/.ssh/id_rsa':
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

$ cd project_name/

modify/create/add files

$ git add .

$ git commit -m "message"
[master d72b82a] modified readme file again
 1 files changed, 1 insertions(+), 1 deletions(-)

$ git push -u origin master
Enter passphrase for key '/c/Users/user_name/.ssh/id_rsa':<type passphrase>
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 300 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@bitbucket.org:folder_name/project_name.git
   cf17705..d72b82a  master -> master
Branch master set up to track remote branch master from origin.

This is how you communicate wit SSH enabled git repo.