Sunday, June 7, 2020

Connect to MySQL running in Docker container from a local machine

Step-by-step Guide to connect with Dockerized MySQL Database from a local machine


λ docker volume create mysql-volume
mysql-volume
λ docker run --name=mk-mysql -p3306:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql/mysql-server:8.0.20
Unable to find image ‘mysql/mysql-server:8.0.20’ locally
8.0.20: Pulling from mysql/mysql-server
λ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d54e7992094b mysql/mysql-server:8.0.20 "/entrypoint.sh mysq…" Less than a second ago Up 4 seconds (health: starting) 0.0.0.0:3306->3306/tcp, 33060/tcp mk-mysql
λ docker logs mk-mysql
λ docker exec -it mk-mysql bash
bash-4.2#
bash-4.2# mysql -u root -p
Enter password:
...mysql> CREATE DATABASE MYSQLTEST;
Query OK, 1 row affected (0.00 sec)
mysql> update mysql.user set host = ‘%’ where user=’root’;
Query OK, 1 row affected (0.02 sec)

Install Dockerized phpMyAdmin

λ docker volume create phpmyadmin-volume
phpmyadmin-volume
λ docker run --name mk-phpmyadmin -v phpmyadmin-volume:/etc/phpmyadmin/config.user.inc.php --link mk-mysql:db -p 82:80 -d phpmyadmin/phpmyadmin
ef21905790dc42bc2e20d449b853d675d4922cb1249131513fdee885fc1088f8
λ docker ps -f "name=mk-phpmyadmin"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef21905790dc phpmyadmin/phpmyadmin "/docker-entrypoint.…" Less than a second ago   Up 10 minutes 0.0.0.0:82->80/tcp mk-phpmyadminλ docker logs mk-phpmyadmin

Note For Mac/Windows:

λ docker-machine ip default

Access MySQL via phpMyAdmin


Friday, June 5, 2020

Web Programlama Ana Sayfası

Takıldığınız yerde GNU Pardus grubundan soru sorabilirsiniz ya da bu depoda issue açabilirsiniz. Teşekkürler , iyi çalışmalar.
  • Not: Kaynak'ta Linux Apache MySQL(MariaDB) PHP olarak geçmektedir ancak GNU/Linux ... olarak değiştirdim. GNU/Linux telaffuzunun kaynaklarda yazım sırasında kullanılmasını önermekteyim. Bu konuyla ilgili issue açıp talebinizi iletebilirseniz sevinirim.


https://github.com/gnupardus/web-howto#web-programlama-ana-sayfas%C4%B1

https://www.knowledgeisle.com/wp-content/uploads/2019/12/

Thursday, June 4, 2020

SEO for Single Page Oracle (SPA) JET Application

This is a quick tip post related to Oracle JET.

SEO (search engine optimization) is a must for a public website or public-facing app. Search engines do indexing well for static HTML pages. Oracle JET on contrary follows SPA (single page application) approach with dynamic UI. This makes it harder for the search engines to build an index for such an app. The same applies to any other SPA implementations with Angular, React, Vue.js, etc.

If you want to build SEO support for Oracle JET, similar solutions as for Angular, React or Vue.js SPAs apps can be applied.

One of the simpler and reliable solutions - generate static HTML pages for Oracle JET SPA app. You can follow this article, it explains how the same can be done for Angular - SEO for Single Page Applications.

No comments:

Multiple Node.js Applications on Oracle Always Free Cloud

What if you want to host multiple Oracle JET applications? You can do it easily on Oracle Always Free Cloud. The solution is described in the below diagram:


You should wrap Oracle JET application into Node.js and deploy it to Oracle Compute Instance through Docker container. This is described in my previous post - Running Oracle JET in Oracle Cloud Free Tier.

Make sure to create Docker container with a port different than 80. To host multiple Oracle JET apps, you will need to create multiple containers, each assigned with a unique port. For example, I'm using port 5000:

docker run -p 5000:3000 -d --name appname dockeruser/dockerimage

This will map standard Node port 3000 to port 5000, accessible internally within Oracle Compute Instance. We can direct external traffic from port 80 to port 5000 (or any other port, mapped with Docker container) through Nginx.

Install Nginx:

yum install nginx

Go to Nginx folder:

cd etc/nginx

Edit configuration file:

nano nginx.conf

Add context root configuration for Oracle JET application, to be directed to local port 5000:

location /invoicingdemoui/ {
     proxy_pass http://127.0.0.1:5000/;
}

To allow HTTP call from Nginx to port 5000 (or other port), run this command (more about it on Stackoverflow):

setsebool -P httpd_can_network_connect 1

Reload Nginx:

systemctl reload nginx

Check Nginx status:

systemctl status nginx

That's all. Your Oracle JET app (demo URL) now accessible from the outside:

Running Oracle JET in Oracle Cloud Free Tier

OOW’19 stands up from recent years OOW conferences with important announcement — Oracle Cloud Free Tier offering. This offering includes two free DB instances and two free compute VM instances. What else you could wish for the side and hobby projects? This is a strong move by Oracle and it should boost Oracle Cloud. Read more about it in Oracle Cloud Free Tier page.
It was interesting to test how to deploy Oracle JET app to Oracle Always Free instance of compute VM. I will not go through the initial steps, related how to create VM instance and enable internet access (for the port 80). You can read all that in a nice write up from Dimitri Gielis post.
Assuming you already have created Oracle JET app and want to deploy it. One way would be to set up Node.js and Nginx on the compute VM and pull app source code from Git. I prefer another way — to go through Docker container, Nginx would act as an HTTP server to redirect requests to Docker container port. But in this post for simplicity reasons, we are not going to look into Nginx setup — will focus only on JET deployment through Docker container.
1. Create an empty Node application (follow these steps):
express — view=pug
2. Add dependencies, go into the Node app and run:
npm install
3. Copy Oracle JET content from web folder into Node app public folder (remove existing files)
4. Inside the Node app, adjust app.js file, comment out these lines:
var usersRouter = require(‘./routes/users’);app.set(‘view engine’, ‘pug’);app.use(‘/users’, usersRouter);
5. Keep only index.js file in router folder
6. Remove template files from views folder
7. Update index.js file to redirect to Oracle JET index.html
router.get(‘/’, function(req, res, next) {
 //res.render(‘index’, { title: ‘Express’ });
 res.sendFile(‘index.html’, {root: ‘./public/’});
 });
8. Note down port 3000 info from bin/www, this is the port Node app will run in Docker container
9. Create Dockerfile inside Node app folder (follow these steps). Content:
FROM node:10# Create app directory
 WORKDIR /usr/src/app# Install app dependencies
 # A wildcard is used to ensure both package.json AND package-lock.json are copied
 # where available (npm@5+)
 COPY package*.json ./RUN npm install
 # If you are building your code for production
 # RUN npm ci — only=production# Bundle app source
 COPY . .EXPOSE 3000
 CMD [ “node”, “./bin/www” ]
10. Create .dockerignore file. Content:
node_modules
 npm-debug.log
11. Build a Docker image locally, by running below command inside the Node app:
docker build -t username/imagename -f ./Dockerfile .
12. Push Docker container to Docker Hub. This way we will be able to pull the container from Oracle compute VM in the cloud:
docker push username/imagename
— — — — — — —
Next steps are executed inside Oracle compute VM. You should connect through SSH to run below commands.
13. Install Docker (run sudo su):
yum install docker-engine
14. Enable Docker:
systemctl enable docker
15. Start Docker:
systemctl start docker
16. Check Docker status:
systemctl status docker.service
17. Check Docker version:
docker version
18. Login into Docker Hub, to be able to pull the container with Node app. If login doesn’t work (access permission issue), run this command: sudo usermod -a -G docker $USER
docker login
19. Run container:
docker run -p 80:3000 -d — name appname username/imagename
Node app with Oracle JET content can be accessed by port 80 using public IP of your Oracle container VM: http://130.61.241.30/index.html
Oracle JET app runs on Oracle container VM free tier:

Originally published at http://andrejusb.blogspot.com.

Docker Commands

# cd /etc/yum.repos.d/
# wget http://yum.oracle.com/public-yum-ol7.repo
# vi public-yum-ol7.repo
 yum install docker-engine


# systemctl start docker
# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.


 systemctl status docker


 docker login container-registry.oracle.com
Username: honglin.su@oracle.com
Password: 
Login Succeeded

# docker pull container-registry.oracle.com/os/oraclelinux:6.9
6.9: Pulling from os/oraclelinux
88710002ea6c: Pull complete 
Digest: sha256:9ee6b162062040c59f6bdc7fd47a9c55f08695c898d517b99bb6d48a0ed9ccf2
Status: Downloaded newer image for container-registry.oracle.com/os/oraclelinux:6.9

# docker pull container-registry.oracle.com/java/serverjre
Using default tag: latest
latest: Pulling from java/serverjre
78a05301de27: Pull complete 
1bd2d038d806: Pull complete 
Digest: sha256:cd18dd865cfd0a3b95732eee6e528ff86a96157221a47af48b388b316b1d4b4b
Status: Downloaded newer image for container-registry.oracle.com/java/serverjre:latest

# docker images
REPOSITORY                                     TAG                 IMAGE ID            CREATED             SIZE
container-registry.oracle.com/os/oraclelinux   6.9                 7a4a8c404142        3 weeks ago         171 MB
container-registry.oracle.com/java/serverjre   latest              289ea39a2a2c        6 weeks ago         377 MB

[root@instance1-nilsys test]# sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   638  100   638    0     0   3167      0 --:--:-- --:--:-- --:--:--  3174
100 11.6M  100 11.6M    0     0  2644k      0  0:00:04  0:00:04 --:--:-- 3513k


[root@instance1-nilsys test]# sudo chmod +x /usr/local/bin/docker-compose
[root@instance1-nilsys test]# docker-compose --version
bash: docker-compose: command not found
[root@instance1-nilsys test]# sudo docker-compose --version
sudo: docker-compose: command not found
[root@instance1-nilsys test]# sudo /usr/local/bin/docker-compose --version
docker-compose version 1.26.0, build d4451659

Deduplicating Data on the Databricks Lakehouse: Making joins, BI, and AI queries “safe by default.”

  Imagine this: your manager asks the AI analytics tool: "What were our top-selling products last quarter?" The AI generates perfe...