<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wildan Aziz</title>
    <description>The latest articles on DEV Community by Wildan Aziz (@wildanazz).</description>
    <link>https://dev.to/wildanazz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F873881%2F75d636c4-9e38-48fd-a32b-1ebcae531d1c.jpeg</url>
      <title>DEV Community: Wildan Aziz</title>
      <link>https://dev.to/wildanazz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wildanazz"/>
    <language>en</language>
    <item>
      <title>Word Embeddings</title>
      <dc:creator>Wildan Aziz</dc:creator>
      <pubDate>Thu, 12 Sep 2024 08:56:28 +0000</pubDate>
      <link>https://dev.to/wildanazz/word-embeddings-19p7</link>
      <guid>https://dev.to/wildanazz/word-embeddings-19p7</guid>
      <description>&lt;h3&gt;What are word embeddings?&lt;/h3&gt;

&lt;p&gt;Word embeddings are a type of word representation used in natural language processing (NLP) and machine learning. They involve mapping words or phrases to vectors of real numbers in a continuous vector space. The idea is that words with similar meanings will have similar embeddings, making it easier for algorithms to understand and process language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f723vvzph0dc5njuj0v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7f723vvzph0dc5njuj0v.jpg" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a bit more detail on how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vector Representation: Each word is represented as a vector (a list of numbers). For example, the word "north" is represented as [0.30059, 0.55598, -0.040589, ...].&lt;/li&gt;
&lt;li&gt;Semantic Similarity: Words that have similar meanings are mapped to nearby points in the vector space. So, "north" and "south" are close to each other, while "north" and "season" are further apart.&lt;/li&gt;
&lt;li&gt;Dimensionality: The vectors are usually of high dimensionality (e.g., 50 to 300 dimensions). Higher dimensions can capture more subtle semantic relationships, but also require more data and computational resources.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Pre trained word embeddings&lt;/h3&gt;

&lt;p&gt;Pre-trained word embeddings are vectors that represent words in a continuous vector space, where semantically similar words are mapped to nearby points. They’re generated by training on large text corpora, capturing syntactic and semantic relationships between words. These embeddings are useful in natural language processing (NLP) because they provide a dense and informative representation of words, which can improve the performance of various NLP tasks.&lt;/p&gt;

&lt;h3&gt;What examples of pre-trained word embeddings?&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Word2Vec: Developed by Google, it represents words in a vector space by training on large text corpora using either the Continuous Bag of Words (CBOW) or Skip-Gram model.&lt;/li&gt;
&lt;li&gt;GloVe (Global Vectors for Word Representation): Developed by Stanford, it factors word co-occurrence matrices into lower-dimensional vectors, capturing global statistical information.&lt;/li&gt;
&lt;li&gt;FastText: Developed by Facebook, it builds on Word2Vec by representing words as bags of character n-grams, which helps handle out-of-vocabulary words better.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Visualizing pre-trained word embeddings can help you understand the relationships and structure of words in the embedding space.
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import libraries.
&lt;pre&gt;
&lt;code&gt;
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.manifold import TSNE
&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Download pre-trained GloVe word vectors &lt;a href="https://nlp.stanford.edu/projects/glove/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.
&lt;pre&gt;
&lt;code&gt;
# Load pre-trained GloVe embeddings
embeddings_index = {}
try:
    with open('glove.6B.50d.txt', encoding='utf-8') as f:
        for line in f:
            values = line.split()
            word = values[0]
            coefs = np.asarray(values[1:], dtype='float32')
            embeddings_index[word] = coefs
except:
    raise("Something error when opening the file.")

words = list(embeddings_index.keys())[:200]
words_vectors = np.array([embeddings_index[word] for word in words])

tsne = TSNE(n_components=2, random_state=0, perplexity=30, max_iter=300)
word_vectors_2d = tsne.fit_transform(words_vectors)
&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Visualizing the word embeddings.
&lt;pre&gt;
&lt;code&gt;
# Convert numpy array to dataframe
df = pd.DataFrame({
    'x': word_vectors_2d[:, 0],
    'y': word_vectors_2d[:, 1],
    'word': words
})

# Set Seaborn style
sns.set(style='whitegrid')

# Create the plot
plt.figure(figsize=(5, 1.9), dpi=1000)
plt.grid(True)
ax = sns.scatterplot(data=df, x='x', y='y', hue='word', palette='tab20', legend=None, s=25, alpha=0.7)

# Customize plot appearance
ax.set(xlabel=None)
ax.set(ylabel=None)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_xlim(-15, 15)  # Adjust these values as needed
ax.set_ylim(-15, 15)

# disabling xticks and yticks by Setting xticks to an empty list
plt.xticks([])
plt.yticks([])

# Show plot
plt.savefig('Word Embeddings 2D.png', bbox_inches='tight', transparent=True, dpi=1000)
plt.show()
&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Clustering of Words: Words that are semantically similar in meaning (according to their embeddings) tend to appear closer together in the plot. For instance, words like "king" and "queen" might form a cluster, while words like "dog" and "cat" would cluster separately in a different region.&lt;/li&gt;
&lt;li&gt;Dimensionality Reduction: The word embeddings, which are typically high-dimensional vectors (e.g., 300-dimensional from Word2Vec or GloVe), have been reduced to 2D. While the original high-dimensional relationships are complex, t-SNE tries to preserve the local structures in the reduced 2D space, which may cause groups of words that were close in high dimensions to appear near each other in this plot.&lt;/li&gt;
&lt;li&gt;Interpretation: Each point on the plot represents a word, and the distance between points reflects the similarity between the words in their original high-dimensional vector space. Clusters of words likely share semantic similarities, while isolated points might represent words that are more unique or less contextually related to others in the data set.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>nlp</category>
    </item>
    <item>
      <title>Multi-layer Graph Convolutional Network (GCN) Overview</title>
      <dc:creator>Wildan Aziz</dc:creator>
      <pubDate>Tue, 03 Sep 2024 09:33:20 +0000</pubDate>
      <link>https://dev.to/wildanazz/multi-layer-graph-convolutional-network-gcn-overview-fl5</link>
      <guid>https://dev.to/wildanazz/multi-layer-graph-convolutional-network-gcn-overview-fl5</guid>
      <description>&lt;h3&gt;Multi-layer Graph Convolutional Network (GCN)&lt;/h3&gt;

&lt;p&gt;Multi-layer GCN is a type of neural network specifically designed for graph-structured data, where nodes represent entities and edges represent relationships between these entities. This neural network can be used to perform various tasks on graph dataset, such as node classification, link prediction, or clustering.&lt;/p&gt; 

&lt;p&gt;The Facebook Large Page-Page Network Dataset is a well-known dataset used for research in graph neural networks (GNNs) and social network analysis. This dataset represents a network of Facebook pages (nodes) where edges indicate mutual likes between pages.&lt;/p&gt;

&lt;p&gt;Here's a step-by-step breakdown of how you can apply a multi-layer GCN to the Facebook Large Page-Page Network Dataset:&lt;/p&gt;

&lt;h4&gt;1. Data preparation&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Nodes&lt;/b&gt;: Each node represents a Facebook page.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Edges&lt;/b&gt;: Edges represent mutual likes between two Facebook pages.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Features&lt;/b&gt;: Typically, each node would have a feature vector (e.g., one-hot encoded or continuous attributes). If the dataset doesn’t provide features, you may consider using identity matrices or applying node embeddings.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;2. Graph Convolutional Network (GCN) Architecture&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Input Layer&lt;/b&gt;: Takes node features and the adjacency matrix as inputs.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Hidden Layers&lt;/b&gt;: Each layer performs a graph convolution operation, aggregating information from the neighboring nodes. The depth (number of layers) depends on the complexity of the task.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Output Layer&lt;/b&gt;: For tasks like node classification, this layer produces a label prediction for each node. For link prediction, this layer could output the probability of an edge between pairs of nodes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;3. GCN Layers&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Graph Convolution Layer&lt;/b&gt;: Each GCN layer can be mathematically described as.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;4. Training the GCN&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Loss Function&lt;/b&gt;: For node classification, you might use cross-entropy loss. For link prediction, a binary cross-entropy loss is common.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Optimizer&lt;/b&gt;: Stochastic Gradient Descent (SGD), Adam, or another optimizer to minimize the loss function.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Batching&lt;/b&gt;: Due to the potentially large size of the graph, batching techniques like GraphSAGE or minibatch gradient descent can be useful.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;4. Evaluation&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Node Classification&lt;/b&gt;: Measure accuracy, F1-score, or other metrics depending on the task.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Link Prediction&lt;/b&gt;: Use metrics like AUC-ROC or Precision-Recall.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;5. Implementation&lt;/h4&gt;

&lt;p&gt;You can implement a multi-layer GCN using frameworks like PyTorch, which provide efficient operations on large-scale graphs.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2ltw6z4hilj823yvy7i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2ltw6z4hilj823yvy7i.png" width="" height=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2w9ozb035v93seta9o2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2w9ozb035v93seta9o2d.png" width="" height=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6qzcwfx37zxde1k6rw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6qzcwfx37zxde1k6rw8.png" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Running Machine Learning Model in Azure Function</title>
      <dc:creator>Wildan Aziz</dc:creator>
      <pubDate>Fri, 25 Aug 2023 14:49:30 +0000</pubDate>
      <link>https://dev.to/wildanazz/running-machine-learning-model-in-azure-function-2i47</link>
      <guid>https://dev.to/wildanazz/running-machine-learning-model-in-azure-function-2i47</guid>
      <description>&lt;p&gt;☀️☀️☀️&lt;/p&gt;

&lt;p&gt;Hi! How's your weekend? I hope it's great. I've been taking a long break since I moved into a new place. Anyway, I'd like to show you how I managed to utilize Azure Function to run amachine learning model. Hopefully, by the end of this post, you're able to understand how it works.&lt;/p&gt;




&lt;h3&gt;What's Azure Function?&lt;/h3&gt;

&lt;p&gt;Azure Function is just another service among other good services offered by Microsoft Azure. It's known as a serverless solution. That is, it allow us to focus on writing code instead of worrying about server infrastructure.&lt;/p&gt;

&lt;p&gt;So what are the differences between running application on Azure Function and Virtual Machine? This is a good question. Firstly, Azure Function is more cost-effective. In fact, our application will only be charged depending on its running time. Secondly, it's also easier to manage. No need to configure extra settings whatsoever to run application.&lt;/p&gt;

&lt;h3&gt;Requirements&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.python.org/downloads/release/python-370/"&gt;Python 3.7&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://go.microsoft.com/fwlink/?linkid=2174087"&gt;Azure Functions Core&lt;/a&gt; (Not a hard requirement, but will make life easier)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt; + &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions"&gt;Azure Function Extension&lt;/a&gt; (Again, not a hard requirement)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-python"&gt;Azure Function Service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview"&gt;Azure Storage Account&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A machine learning model&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Steps&lt;/h3&gt;

&lt;p&gt;In this article, we're making use of Graph Convolutional Network (GCN) machine learning model. To give more detail, it's a specific type of neural network model that accepts a graph data as an input. It then outputs a visualization of the graph's node embeddings. If you're interested to learn more about GCN, feel free to check out this &lt;a href="https://tkipf.github.io/graph-convolutional-networks/"&gt;blog&lt;/a&gt; first. Otherwise, go ahead clone the repository &lt;a href="https://github.com/wildanazz/gcn.git"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Open the __init__.py and read the code carefully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E0A3U1i9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2res7865ycvr3efsejg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E0A3U1i9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2res7865ycvr3efsejg.png" width="800" height="847"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice there are HTTP request and response in the code. That is because our function is making use of a HTTP trigger. If you don't know what HTTP trigger is, it's simply a method to let us invoke our function using HTTP request. There are several triggers available to use in Azure Function such as HTTP, timer, and blob.&lt;/p&gt;

&lt;p&gt;Open the local.settings.json.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JfxrnKw3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra2ixh2wussnmyy1sesa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JfxrnKw3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra2ixh2wussnmyy1sesa.png" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add your storage account connection string. So what's storage account? storage account is an object storage solution offered by the Azure cloud. We're using this storage to store our function's result.&lt;/p&gt;

&lt;p&gt;Use the Azure Functions Core tool to initialize a Python function app.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ func init&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Run the following commands to create and activate a virtual environment named .venv. &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ py -3.7 -m venv .venv&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;$ .venv\scripts\activate&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Install the dependencies by running the following command. Installation may take a few minutes.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ pip install --no-cache-dir -r requirements.txt&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Start the function by starting the local Azure Function runtime host.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ func start&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Note:&lt;/h4&gt;

&lt;p&gt;If encounter any errors, make sure the correct version of python is already installed. Otherwise, try upgrading the python pip and install the dependencies again. If the errors still persist, &lt;a href="https://www.google.com/"&gt;Google&lt;/a&gt; is the best place to ask questions.&lt;/p&gt;

&lt;h4&gt;Extra steps (Nice to follow!)&lt;/h4&gt;

&lt;p&gt;We may now test our function. Download graph dataset &lt;a&gt;here&lt;/a&gt;. What is this dataset? It's a preprocessed dataset for our model.&lt;/p&gt;

&lt;p&gt;Open the request.py and change the files location to your dataset file location.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mqrAg-j8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlfrjceuaw7ghl7pp9vf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mqrAg-j8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlfrjceuaw7ghl7pp9vf.png" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Send a POST request to the runtime host on http://localhost:7071/api/nn by executing the code below. The process may take several minutes to complete.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ py -3.7 request.py&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N_FDl6Ui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tr1ydkw13x438mbxhviz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N_FDl6Ui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tr1ydkw13x438mbxhviz.png" width="800" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to get the function's public endpoint, we need to deploy our function on cloud. Check out the complete documentation on how to &lt;a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies?tabs=windows"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;We've learned how to run a machine learning model with Azure Function by following the steps above. I hope you understand how Azure Function works in general by now. It's also important to note that it doesn't necessarily have to be a complex application, such as machine learning model, to run with Azure Function. We can use it for as simple as APIs that update a single row or column in database.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>cloud</category>
      <category>azurefunctions</category>
    </item>
    <item>
      <title>Deploy Docker Application to Virtual Machine Using Github Actions (CI/CD)</title>
      <dc:creator>Wildan Aziz</dc:creator>
      <pubDate>Thu, 24 Aug 2023 02:52:20 +0000</pubDate>
      <link>https://dev.to/wildanazz/deploy-docker-application-to-virtual-machine-using-github-actions-cicd-3p4d</link>
      <guid>https://dev.to/wildanazz/deploy-docker-application-to-virtual-machine-using-github-actions-cicd-3p4d</guid>
      <description>&lt;p&gt;Hi there! A quick question. Have you ever been unexpectedly productive during weekend? I remember spending all day doing a research on whether or not cereal was a soup 🥁.&lt;/p&gt;

&lt;p&gt;Back to the topic, Microservice architecture has been quite popular for years. When building an application for Microservices, we probably want it to be deployed on a virtual machine let's say for scalling purposes. &lt;/p&gt;

&lt;p&gt;In addition, a server automation can be very useful for us since it automates our application build, test, and deployment pipeline before deploying it to a virtual machine.&lt;/p&gt;

&lt;p&gt;This post will help you carefully how to deploy your containerized application on a virtual machine using GitHub actions (CI/CD).&lt;/p&gt;




&lt;h3&gt;Prerequisites&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Virtual machine - A running virtual machine instance. For this demo, I'm using a DigitalOcean droplet as I have it running already. But there shouldn't be a big difference with other virtual machine running on cloud platforms such as Amazon and Google Cloud Platform.&lt;/li&gt;
&lt;li&gt;Docker - An open source software that consist of useful tools to containerize and manage our application. The docker software needs to be installed in the running virtual machine instance.&lt;/li&gt;
&lt;li&gt;Git - A distributed version control system to manage our application code.&lt;/li&gt;
&lt;li&gt;Web Application - An application server. A code example solely for demo can be viewed on github &lt;a href="https://github.com/wildanazz/demo-web-application"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;What are the steps?&lt;/h3&gt;

&lt;p&gt;There are three files that are important for our deployment process.&lt;/p&gt;

&lt;p&gt;workflow.yml tells us how our application deployed in a virtual machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--COW1jrld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28whbton44qz5nxvrvf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--COW1jrld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28whbton44qz5nxvrvf6.png" alt="workflow" width="800" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dockerfile is a set of instructions that run in a sequence in order to build an image of our application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z5HULBTR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wc6aw90kquwvos0uzvwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z5HULBTR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wc6aw90kquwvos0uzvwb.png" alt="dockerfile" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.dockerignore is a file that tells the docker what file(s) are not to include in the build process&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oyZBQqEw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0dz8ij4epm4wy1ok27i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oyZBQqEw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0dz8ij4epm4wy1ok27i.png" alt="dockerignore" width="480" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Configure Nginx Reverse Proxy on Ubuntu VMs + SSL Encryption</title>
      <dc:creator>Wildan Aziz</dc:creator>
      <pubDate>Tue, 16 May 2023 19:31:39 +0000</pubDate>
      <link>https://dev.to/wildanazz/configure-nginx-reverse-proxy-on-ubuntu-vms-ssl-encryption-o4m</link>
      <guid>https://dev.to/wildanazz/configure-nginx-reverse-proxy-on-ubuntu-vms-ssl-encryption-o4m</guid>
      <description>&lt;p&gt;Hi folks! I recently just decided to host my own personal website on a cloud virtual machine. I've experimented a lot of things from doing it and now I'm more than excited to share some of my experiences. This article shows how I configured a reverse proxy and SSL encryption using Nginx.&lt;/p&gt;




&lt;h3&gt;What is a reverse proxy?&lt;/h3&gt;

&lt;p&gt;It's literally another server that sits in front of our website server. That said, whenever a request comes from a client to our website server, it will be intercepted by the reverse proxy server.&lt;/p&gt;

&lt;h3&gt;Why do we even need one?&lt;/h3&gt;

&lt;p&gt;There are, of course, advantages of using a reverse proxy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Load balancing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Protection from attacks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SSL Encryption&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caching&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Setting up project&lt;/h3&gt;

&lt;h4&gt;Key technologies used&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Virtual Machine - A running virtual machine instance. There are many virtual machines available for rent such as &lt;a href="https://aws.amazon.com/ec2/"&gt;Amazon EC2&lt;/a&gt;, &lt;a href="https://cloud.google.com/compute"&gt;Google Compute Engine&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-ca/products/virtual-machines/"&gt;Azure Virtual Machine&lt;/a&gt;, etc.&lt;/li&gt;
&lt;li&gt;Domain Name - A registered domain name. Domain registrars like &lt;a href="https://www.namecheap.com/"&gt;Namecheap&lt;/a&gt;, &lt;a href="https://domains.google.com/registrar/"&gt;Google Domains&lt;/a&gt;, and &lt;a href="https://www.godaddy.com/"&gt;GoDaddy&lt;/a&gt; provide and let us manage domain names.&lt;/li&gt;
&lt;li&gt;Web Application - A server application. View code example on github &lt;a href="https://github.com/wildanazz/demo-web-application"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Nginx - Open source software that's often used for web serving and reverse proxying.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;How it works&lt;/h3&gt;

&lt;h4&gt;Configuring Nginx as a reverse proxy&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Install Nginx and make sure it runs successfully.
&lt;pre&gt;
&lt;code&gt;$ sudo apt update&lt;/code&gt;
&lt;code&gt;$ sudo apt install nginx&lt;/code&gt;
&lt;code&gt;$ sudo service nginx status&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Edit server configuration file in /etc/nginx/sites-available/.
&lt;pre&gt;
&lt;code&gt;$ sudo nano /etc/nginx/sites-available/wildanazz.com&lt;/code&gt;
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BFwMWhy_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pkubsk3ke84557e4cioh.png" alt="NGINX Configuration" width="800" height="586"&gt;
&lt;/li&gt;
&lt;li&gt;Make sure that there are no syntax errors in the server configuration file.
&lt;pre&gt;
&lt;code&gt;$ sudo nginx -t&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Enable the server configuration file by creating a link from sites-available directory to sites-enabled directory.
&lt;pre&gt;
&lt;code&gt;$ sudo rm link /etc/nginx/sites-enabled/default&lt;/code&gt;
&lt;code&gt;$ sudo ln -s /etc/nginx/sites-available/wildanazz.com /etc/nginx/sites-enabled/wildanazz.com&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Testing application&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Clone a demo server application.
&lt;pre&gt;
&lt;code&gt;$ git clone https://github.com/wildanazz/demo-web-application.git&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Run it.
&lt;pre&gt;
&lt;code&gt;$ sudo apt install nodejs &amp;amp;&amp;amp; sudo npm install yarn -g&lt;/code&gt;
&lt;code&gt;$ cd demo&lt;/code&gt;
&lt;code&gt;$ yarn --frozen-lockfile &amp;amp;&amp;amp; yarn start&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Copy and enter the ip address of the running virtual machine in a browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Installing SSL/TLS certificate&lt;/h4&gt;

&lt;p&gt;Before installing SSL/TLS certificate, the registered domain name needs to be pointing to the running virtual machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Certbot to obtain a free SSL certificate.
&lt;pre&gt;
&lt;code&gt;$ sudo snap install --classic certbot&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Run this code to let Certbot edit Nginx configuration automatically.
&lt;pre&gt;
&lt;code&gt;$ sudo certbot --nginx&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Certbot can also renew the certificate automatically before it expires by running this code.
&lt;pre&gt;
&lt;code&gt;$ sudo certbot renew --dry-run&lt;/code&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Summary&lt;/h3&gt;

&lt;p&gt;In this article, I discussed how I set up Nginx reverse proxy server and added a SSL certificate for my website from the ground up. If you decide to host your own website on a virtual machine, I highly recommend you to utilize a reverse proxy server. If you have found something I could improve or that you would have done differently? Let me know in the comments.&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>cloud</category>
      <category>azure</category>
      <category>security</category>
    </item>
  </channel>
</rss>
