Skip to content

Commit

Permalink
Update dev environment to F40
Browse files Browse the repository at this point in the history
- Update container deployment
- Update vagrant deployment

Signed-off-by: Michal Konecny <[email protected]>
  • Loading branch information
Zlopez committed May 27, 2024
1 parent 66a36a2 commit 571ac8e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Containerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ RUN pip install dist/*.whl

# Hotfix for social_auth-sqlalchemy
# Should be removed when we switch to something else
RUN sed -i 's/base64.encodestring/base64.encodebytes/g' /usr/local/lib/python3.11/site-packages/social_sqlalchemy/storage.py
RUN sed -i 's/base64.encodestring/base64.encodebytes/g' /usr/local/lib/python3.12/site-packages/social_sqlalchemy/storage.py

CMD ["sh","-c", "poetry build && pip install dist/*.whl && eval '$START_COMMAND'"]
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "fedora/38-cloud-base"
config.vm.box = "fedora/40-cloud-base"

# Forward traffic on the host to the development server on the guest
config.vm.network "forwarded_port", guest: 5000, host: 5000
Expand Down
13 changes: 0 additions & 13 deletions ansible/docker-playbook.yml

This file was deleted.

5 changes: 3 additions & 2 deletions ansible/roles/anitya-dev/files/anitya.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ After=network.target
Documentation=https://github.com/fedora-infra/anitya/

[Service]
Environment="FLASK_APP=/home/vagrant/devel/runserver.py"
Environment="FLASK_APP=anitya.wsgi"
Environment="FLASK_DEBUG=1"
Environment="ANITYA_WEB_CONFIG=/home/vagrant/anitya.toml"
ExecStart=flask run --host 0.0.0.0 --port 5000
ExecStart=poetry run flask run --host 0.0.0.0 --port 5000
WorkingDirectory=/home/vagrant/devel
Type=simple

[Install]
Expand Down
8 changes: 4 additions & 4 deletions ansible/roles/anitya-dev/tasks/db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
replace:
dest: /home/vagrant/alembic.ini
regexp: "^script_location = anitya.*$"
replace: "script_location = devel/anitya/db/migrations"
replace: "script_location = /home/vagrant/devel/anitya/db/migrations"

- name: Switch the database connection to postgres
replace:
Expand All @@ -67,15 +67,15 @@

- name: Apply database migrations
become_user: "{{ ansible_env.SUDO_USER }}"
command: python3 -m alembic.config upgrade head
command: poetry run alembic -c /home/vagrant/alembic.ini upgrade head
args:
chdir: /home/vagrant/
chdir: /home/vagrant/devel
when: import_production_database

- name: Create database schema
become_user: "{{ ansible_env.SUDO_USER }}"
shell: >
python createdb.py && touch ~/.schema-created
poetry run python createdb.py && touch ~/.schema-created
args:
creates: /home/vagrant/.schema-created
chdir: /home/vagrant/devel
Expand Down
35 changes: 21 additions & 14 deletions ansible/roles/anitya-dev/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
name: [
git,
vim-enhanced,
poetry,
python-devel,
python36,
python37,
python3-black,
python3-tox,
tmux
Expand All @@ -33,21 +32,16 @@
dnf:
name: [
#python3-sphinxcontrib-httpdomain,
# The version 2.0 will be available in F40
#python3-sqlalchemy_schemadisplay
python3-sqlalchemy_schemadisplay
]
state: present

# Anitya needs 2.0 version of sqlalchemy_schemadisplay,
# but it's not available in <F40, let's install it from pip till
# F40 vagrant box will be available
# Anitya needs 1.8.0 version of sphinxcontrib-httpdomain,
# but it's not available in Fedora yet, let's install it from pip now
- name: Install pip dev dependencies
pip:
name:
[
sqlalchemy_schemadisplay,
sphinxcontrib-httpdomain
]
state: present
Expand All @@ -68,6 +62,7 @@
python3-toml,
python3-semver,
python3-sqlalchemy,
python3-sqlalchemy_schemadisplay,
python3-sseclient,
python3-straight-plugin,
python3-wtforms
Expand All @@ -92,12 +87,24 @@
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel/anitya/static

- name: Use system-side-packages in poetry virtualenv
ansible.builtin.command:
cmd: poetry config virtualenvs.options.system-site-packages true

- name: Install Anitya into the virtualenv
pip:
name:
- "{{ anitya_src }}"
extra_args: "-e"
tags: install
ansible.builtin.command:
cmd: poetry install
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel
become_user: "{{ ansible_env.SUDO_USER }}"

- name: Install Anitya into the virtualenv
ansible.builtin.command:
cmd: poetry env info -p
register: poetry_location
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel
become_user: "{{ ansible_env.SUDO_USER }}"

- name: Create user systemd directory
become_user: "{{ ansible_env.SUDO_USER }}"
Expand Down Expand Up @@ -125,7 +132,7 @@
# Could be removed when we move away from social_auth
- name: Hotfix for social_auth
replace:
path: /usr/local/lib/python3.11/site-packages/social_sqlalchemy/storage.py
path: "{{ poetry_location.stdout }}/lib/python3.12/site-packages/social_sqlalchemy/storage.py"
regexp: 'base64\.encodestring'
replace: 'base64.encodebytes'

Expand Down
2 changes: 0 additions & 2 deletions ansible/vagrant-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
vars:
roles:
- role: anitya-dev
vars:
anitya_src: "file:///home/{{ ansible_env.SUDO_USER }}/devel"
3 changes: 2 additions & 1 deletion container-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: .
dockerfile: Containerfile.dev
args:
FEDORA_VERSION: 38
FEDORA_VERSION: 40
container_name: "anitya-web"
ports:
- "127.0.0.1:5000:5000"
Expand All @@ -17,6 +17,7 @@ services:
restart: unless-stopped
environment:
- FLASK_APP=anitya.wsgi
- FLASK_DEBUG=1
- START_COMMAND=flask run -h 0.0.0.0
depends_on:
postgres:
Expand Down

0 comments on commit 571ac8e

Please sign in to comment.