Categories
Linux Technology

apt update vs apt upgrade: What’s the difference?

https://dev.to/kcdchennai/apt-update-vs-apt-upgrade-whats-the-difference-2ff8

Categories
devops Technology

DockerFile properties

ARG

On building a docker image you may want to have some variables (you can also have them in docker-compose)

you can define ARG in docker file (you can also set default value for them in docker file)

for example :

# in docker file
ARG some_variable_name = xxxx
ARG uid

#on building image : 
$ docker build --build-arg some_variable_name=a_value

ENV

ENV variables are also available during the build, as soon as you introduce them with an ENV instruction. However, unlike ARG, they are also accessible by containers started from the final image. ENV values can be overridden when starting a container, more on that below.

# no default value
ENV hey
# a default value
ENV foo /bar
# or ENV foo=/bar

# ENV values can be used during the build
ADD . $foo
# or ADD . ${foo}
# translates to: ADD . /bar


on running docker : 
$ docker run -e "env_var_name=another_value" alpine env

RUN

for example :

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd

ADD , COPY

COPY and ADD are both Dockerfile instructions that serve a similar purpose. They let you copy files from a specific location into a Docker image.

ADD

ADD  does that same but in addition, it also supports 2 other sources. 

  1. A URL instead of a local file/directory.
  2. Extract tar from the source directory into the destination.

COPY

COPY takes in a source and destination. It only lets you copy in a local or directory from your host (the machine-building the Docker image) into the Docker image itself.

for example :

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR

for example:

# Set working directory
WORKDIR /var/www

USER

for example:

USER $user
Categories
devops Linux Technology

How to run our own Smart DNS to bypass geo restrictions – let’s run something like shecan.ir

The article in the link below helps in this way.

Check it out.

https://maj0rmil4d.medium.com/how-to-run-our-own-smart-dns-to-bypass-geo-restrictions-beeeab4f82d7

Categories
Linux Shell Technology

Linux Crucial commands – Chmod Command in Linux (File Permissions)- part 2

See file permissions :

ls -l example.txt

#output
-rw-r--r-- 12 linuxize users 12.0K Apr  8 20:51 example.txt
|[-][-][-]-   [------] [---]
| |  |  | |      |       |
| |  |  | |      |       +-----------> 7. Group
| |  |  | |      +-------------------> 6. Owner
| |  |  | +--------------------------> 5. Alternate Access Method
| |  |  +----------------------------> 4. Others Permissions
| |  +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type

What is chmod in Linux:

in UNIX OSes, chmod is a command to change files and directories permissions.

chmod stands for “change mode”.

one of the most important reasons for Linux to be on the list of safe OSes is that every user has their own permission for each file and folder.

Categories
Best practice devops Programming Technology Web Development

Implement Rest APIs more efficient

Most web applications are implemented based on Rest Full APIs and as I researched huge part of them are not implemented based on best practices and clean code principles, so I decided to collect some points in a couple of posts to help make them more efficient APIs and Applications.

Let’s Look at other kinds of APIs

you can easily research and find out more about all of these kine of API design methodologies but here I’m going to just collect best part of them to create a document to implement Rest API in best practice.

Graphql

the best part of graphql is that you can design your API for the front end to just get whatever need, not more.

it can bring us better speed because less amount of packets is transferring over the network.

gRPC

Socket

Categories
devops Technology

What is Docker?

This article is for you if you …

If you are a developer and you are going to start working with docker, and you already don’t know even the concepts of Docker, this article series is for you.

It was a little confusing for me when I started working with docker, so I decided to publish some articles for bits of help who are beginners to Docker or who want to review the concepts.

Overview of docker

Docker allows users to build independent and isolated development environments in the computer and run their software in a way that we call Container. For example, suppose you need a project with php8.1, but you only have php7.4 on your system(you need the php7.4 version to develop other projects).

In this use case, you can build a docker image that contains your PHP suitable version and your database and other environments and run it as a container by the side of another project in an isolated environment.

Another Docker use case

You are running a Linux environment with different PHP, database, composer, node.js, npm, and…

And your teammate is working on mac os with a completely different environment .

What is the solution?

How can you work on the same project simultaneously in a different environment?

How to deploy a project if the server can’t provide project requirements based on our development environment?

  • docker can solve this problem by build isolated environments in the server and provide exactly requirements of peject in the isolated space.

download and install docker :

  • https://www.docker.com/get-started/