From ee7e8dcdc007a519bb9e009eec25466f251e2130 Mon Sep 17 00:00:00 2001 From: Yariv Rachmani Date: Wed, 28 Dec 2022 00:39:36 +0200 Subject: [PATCH] Container version *) Build with docker file podman build -f Containerfile -t fedora36-django *) Push to quay To Run pull from Quay podman run -v ${PWD}:/vagrant:Z -p 8000:8000 -it /bin/bash = quay.io/yarboa/django-fedora36 Removed pipeenv from gihub workflow --- .github/workflows/flake8.yml | 8 +- .github/workflows/pytest.yml | 8 +- Containerfile | 25 ++++++ Pipfile | 15 ---- Pipfile.lock | 149 ----------------------------------- Vagrantfile | 77 ------------------ app_setup.sh | 9 ++- requirements.txt | 32 ++++++++ 8 files changed, 70 insertions(+), 253 deletions(-) create mode 100644 Containerfile delete mode 100644 Pipfile delete mode 100644 Pipfile.lock delete mode 100644 Vagrantfile create mode 100644 requirements.txt diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 4bc7e31..029b429 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -6,11 +6,11 @@ jobs: runs-on: ubuntu-20.04 container: fedora:36 steps: - - name: Install Pipenv and Git - run: dnf install -y pipenv git + - name: Install Git + run: dnf install -y git pip - name: Checkout code uses: actions/checkout@v2 - name: Setup environment - run: pipenv sync --dev + run: pip install -r requirements.txt - name: Run Flake8 - run: pipenv run flake8 --max-line-length 120 + run: flake8 --max-line-length 120 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 1f235b8..0c8960e 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -6,11 +6,11 @@ jobs: runs-on: ubuntu-20.04 container: fedora:36 steps: - - name: Install Pipenv and Git - run: dnf install -y pipenv git + - name: Install Git + run: dnf install -y git pip - name: Checkout code uses: actions/checkout@v2 - name: Setup environment - run: pipenv sync --dev + run: pip install -r requirements.txt - name: Run PyTest - run: pipenv run pytest -v + run: pytest -v diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..07a3078 --- /dev/null +++ b/Containerfile @@ -0,0 +1,25 @@ +# fedora-36 +FROM registry.fedoraproject.org/fedora:36 + +WORKDIR /vagrant + +COPY requirements.txt /vagrant + +RUN \ + dnf -y install \ +# python3 \ + sqlite \ + pip \ + gcc \ + python3-devel \ + && \ + dnf clean all + +RUN \ + python3 -m pip install -r requirements.txt + +COPY app_setup.sh /vagrant + +ENTRYPOINT /bin/bash /vagrant/app_setup.sh + +EXPOSE 8000/tcp diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 87805b7..0000000 --- a/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -flake8 = "*" -pytest-django = "*" -pytest = "*" - -[packages] -django = "*" - -[requires] -python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 6736a4d..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,149 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "7afd9cf1589fdc87c2fd2473419aa7715edff8124a9b1c940e5513eead3043f2" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.10" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "asgiref": { - "hashes": [ - "sha256:1d2880b792ae8757289136f1db2b7b99100ce959b2aa57fd69dab783d05afac4", - "sha256:4a29362a6acebe09bf1d6640db38c1dc3d9217c68e6f9f6204d72667fc19a424" - ], - "markers": "python_version >= '3.7'", - "version": "==3.5.2" - }, - "django": { - "hashes": [ - "sha256:678bbfc8604eb246ed54e2063f0765f13b321a50526bdc8cb1f943eda7fa31f1", - "sha256:6b1de6886cae14c7c44d188f580f8ba8da05750f544c80ae5ad43375ab293cd5" - ], - "index": "pypi", - "version": "==4.1.3" - }, - "sqlparse": { - "hashes": [ - "sha256:0323c0ec29cd52bceabc1b4d9d579e311f3e4961b98d174201d5622a23b85e34", - "sha256:69ca804846bb114d2ec380e4360a8a340db83f0ccf3afceeb1404df028f57268" - ], - "markers": "python_version >= '3.5'", - "version": "==0.4.3" - } - }, - "develop": { - "attrs": { - "hashes": [ - "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6", - "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c" - ], - "markers": "python_version >= '3.5'", - "version": "==22.1.0" - }, - "exceptiongroup": { - "hashes": [ - "sha256:542adf9dea4055530d6e1279602fa5cb11dab2395fa650b8674eaec35fc4a828", - "sha256:bd14967b79cd9bdb54d97323216f8fdf533e278df937aa2a90089e7d6e06e5ec" - ], - "markers": "python_version < '3.11'", - "version": "==1.0.4" - }, - "flake8": { - "hashes": [ - "sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7", - "sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181" - ], - "index": "pypi", - "version": "==6.0.0" - }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, - "mccabe": { - "hashes": [ - "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", - "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" - ], - "markers": "python_version >= '3.6'", - "version": "==0.7.0" - }, - "packaging": { - "hashes": [ - "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", - "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" - ], - "markers": "python_version >= '3.6'", - "version": "==21.3" - }, - "pluggy": { - "hashes": [ - "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", - "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" - ], - "markers": "python_version >= '3.6'", - "version": "==1.0.0" - }, - "pycodestyle": { - "hashes": [ - "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053", - "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610" - ], - "markers": "python_version >= '3.6'", - "version": "==2.10.0" - }, - "pyflakes": { - "hashes": [ - "sha256:12da339341ba8b9071e185d4717bef732fdb4f4400b9f4a1d0d6bbc362bf7760", - "sha256:e38cbaa285564388a9622d7e440445d40c508d8fbf96e0c0f3ef28e47d8ba8a2" - ], - "markers": "python_version >= '3.6'", - "version": "==3.0.0" - }, - "pyparsing": { - "hashes": [ - "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - ], - "markers": "python_full_version >= '3.6.8'", - "version": "==3.0.9" - }, - "pytest": { - "hashes": [ - "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71", - "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59" - ], - "index": "pypi", - "version": "==7.2.0" - }, - "pytest-django": { - "hashes": [ - "sha256:c60834861933773109334fe5a53e83d1ef4828f2203a1d6a0fa9972f4f75ab3e", - "sha256:d9076f759bb7c36939dbdd5ae6633c18edfc2902d1a69fdbefd2426b970ce6c2" - ], - "index": "pypi", - "version": "==4.5.2" - }, - "tomli": { - "hashes": [ - "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" - ], - "markers": "python_version < '3.11'", - "version": "==2.0.1" - } - } -} diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 65a7ad5..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,77 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - # config.vm.box = "base" - config.vm.box = "fedora/36-cloud-base" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1" - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - config.vm.synced_folder ".", "/vagrant", type: "virtualbox" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - config.vm.provider "virtualbox" do |vb| - vb.memory = "1024" - end - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL - config.vm.provision "shell", path: "app_setup.sh", privileged: false -end diff --git a/app_setup.sh b/app_setup.sh index d199f5a..bb52155 100644 --- a/app_setup.sh +++ b/app_setup.sh @@ -5,16 +5,17 @@ # Install Pipenv, the -n option makes sudo fail instead of asking for a # password if we don’t have sufficient privileges to run it -sudo -n dnf install -y pipenv +#sudo -n dnf install -y pipenv cd /vagrant # Install dependencies with Pipenv -pipenv sync +#pipenv sync # Run database migrations -pipenv run python manage.py migrate +python3 manage.py migrate # run our app. Nohup and “&” are used to let the setup script finish # while our app stays up. The app logs will be collected in nohup.out -(setsid pipenv run python manage.py runserver 0.0.0.0:8000 > runserver.log 2>&1 &) +#(setsid python3 manage.py runserver 0.0.0.0:8000 > runserver.log 2>&1 )& +python3 manage.py runserver 0.0.0.0:8000 > runserver.log 2>&1 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..43f9500 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,32 @@ +# Base: ubi9 + +# Django +asgiref==3.5.0 +Django==4.0.3 +sqlparse==0.4.2 + +# pytest +attrs==21.4.0 +iniconfig==1.1.1 +packaging==21.3 +pluggy==1.0.0 +py==1.11.0 +pyparsing==3.0.7 +pytest==7.1.0 +pytest-django==4.5.2 +tomli==2.0.1 + +# linters +## flake8 +flake8==4.0.1 +mccabe==0.6.1 +pycodestyle==2.8.0 +pyflakes==2.4.0 + +# black (formatter) +black==22.1.0 +click==8.0.4 +mypy-extensions==0.4.3 +pathspec==0.9.0 +platformdirs==2.5.1 +typing-extensions==4.1.1