Giter VIP home page Giter VIP logo

packiot-fsc's Introduction

PackIOT FSC :: Challenge #1

Technical assessment for the position of full-stack software developer at PackIOT.

0. Table of contents

1. Preliminaries

In order to build the project, you must have already installed and configured in your workspace:

1.1. Installing pip and virtualenv

With the correct Python distribution, at the terminal, execute the following commands:

$ sudo apt install python3-pip python3-virtualenv

1.2. Virtual environment

After you cloned this project, you must install its Python dependencies. So, at the project's root, execute in the terminal:

$ virtualenv --python=python3 venv                  # Creates the virtual env
$ source venv/bin/activate                          # Make it active inside the project
$ pip install --upgrade pip --no-cache-dir          # Upgrade the package manager
$ pip install -r requirements.txt --no-cache-dir    # Install dependencies listed in the .txt file

2. Building and running

To construct the containers which encapsulate the PostgreSQL database server and the pgAdmin 4 web application, a suite of scripts was implemented in Python, in order to automate the users' interaction with the Docker and Compose actions. The documentation about these scripts can be found here.

The aforementioned containers and its associated images are built with Docker Compose, where the corresponding services are all declared in the YAML file, at the project's root. These services are:

  • pgsqlserver: Runs the container that encapsulates a proper PostgreSQL server. The image for this container (Dockerfile) was implemented locally, for reasons of database automation;
  • pgadmin: The web interface that consumes the PostgreSQL database, and for that it can not run without the previous service been built. It uses an officially distributed image, downloaded from Docker Hub.

2.1. PostgreSQL server

We use here the automation script to perform building and runnning. At the project's root, execute in the terminal:

2.1.1. For building:

$ ./scripts/devenv.py build pgsqlserver 

2.1.2. For running:

$ ./scripts/devenv.py startwlogs pgsqlserver # Starts the container in detached mode and shows the logs

Note: The database for this challenge (packiotfscdb) is created when the container is started (you can see in the logs). More information on how to interact with it can be found here.

2.2. pgAdmin 4

Similarly, we use the automation script to build and run this service, with the difference that the building part is not done separatedly, because the image for this container is obtained externally, i.e., there is no Dockerfile. So, you just need to run in the terminal:

$ ./scripts/devenv.py startwlogs pgadmin

With the container up and running, you can now access the pgAdmin's UI via browser. The credentials for signing in are defined in the container's .env file.

To access the database and its respective schema, you'll have to add a server and set up the connection to it. To do that, you can check out the official pgAdmin 4 documentation. It's pretty straightforward. The necessary database credentials are defined in the pgsqlserver container's .env file.

Note: When specifying the hostname in the connection dialog, you must enter the name of the service listed in the Docker Compose YAML file, i.e., (pgsqlserver).

3. Where to now?

packiot-fsc's People

Contributors

guligon90 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.