New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2 #83
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think alot of the code in this PR can be removed. Our build steps have changed quite a bit to match fragdenstaat_de
after [this PR],(#78) in particular these can be removed:
froide/*
local_settings.py
settings.py
We can then rewrite the Dockerfile &
docker-compose.local.yml` file to match the instructions here - with an edge case for somehow handling the first initial seeding of the database.
froide/.babelrc
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this froide
directory for Dockerization (at least after #78 got merged in). Side note, but the froide
directory exists under ./src/froide
after a pip install -r requirements.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The froide directory is there to build the image. It's a bit messy but I basically copied the okde froide repo into the froide directory so that I could build a clean version of the latest froide code. I figured having that alongside our code would help us update the froide code to get the functionality that we need.
settings.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure of the settings file has changed in main
to closely resemble the file structure over in fragdenstaat_de
- check out uipa_org/settings/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look at that.
local_settings.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed - check out uipa_org/settings/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local_settings.py
and settings.py
files are there to load into the image when it's built. Look at the Dockerfile to see where this comes into play.
docker-compose.local.yml
Outdated
|
||
services: | ||
app: | ||
image: ssthapa/uipa_backend:0.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love having a separate image here - but it's fine. We should have instructions on how to switch this out/publish our own containers though if so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should actually have a 0.8, it's 0.9 because I was using that for testing. I'll fix that. The image is generated from the Dockerfile in the top level directory. We can just change the tag to uipa_backend:x
to use a locally built copy. We need to document this though.
#ARG INSTALL_PYTHON_VERSION=${INSTALL_PYTHON_VERSION:-3.8.12} | ||
#FROM python:${INSTALL_PYTHON_VERSION}-slim-bullseye AS base | ||
# FROM debian:bullseye-slim AS base | ||
FROM ssthapa/django5:0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's something I built. The source is at https://github.com/sthapa/django-images
COPY pyproject.toml /srv/django/pyproject.toml | ||
|
||
RUN apk update && \ | ||
apk add rust cargo qpdf qpdf-dev poppler poppler-dev g++ gdal geos alpine-sdk \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need all of these dependencies? I don't recall ever installing rust
or cargo
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we do, the python ssl module are rust code and with alpine I think pip needs to download and build the python module instead of just installing the pre-compiled verison.
Dockerfile
Outdated
RUN /root/.local/bin/poetry install | ||
|
||
|
||
COPY local_settings.py /srv/django/froide/local_settings.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't need to do this anymore - a Dockerfile matching the steps of https://github.com/codewithaloha/uipa?tab=readme-ov-file#instructions-1 should do the trick (with something handling the edge case of the first initial seed of the data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The settings file doesn't seem to pickup the elasticsearch host from env variables. So I need to have a copy of the settings that tells django to try to connect to es on the network instead of localhost. I need to debug this a bit more but I figured this works for now so people could use this rather than waiting longer.
requirements.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file probably doesn't need to be updated for Dockerization, and can also be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should remove it and use the pyproject.toml
with poetry instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted it, although it sounds like we still use it in our workflow based on last night's session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agreed. 😿
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably change that, I think going with poetry or pyenv would be better than venv initially and then telling people to use the pyproject.toml
when they want to do things for real.
I wasn't able to get this PR working locally as is, is there a permission issue as well somewhere?:
|
I get the same error:
However, an earlier version of
|
Hmm...things seem a bit complicated and opaque. Is there a need to use a special image (ssthapa/uipa_backend)? |
@tyliec you'll need to login to dockerhub to pull the image I think. docker made it more difficult to use without a login. @russtoku we should at the baseline provide a baseline image that works. If devs can change the image reference and use a locally built version but it's a bit more cumbersome and may take 5-10 minutes to build initially. Also with the pre-built image, it makes building a local image much faster. |
After running I have to disagree with the use of While Docker containers can be a way to quickly get up to speed, not everyone wants to and is able to use Docker locally. While it may be OK to use I'm OK with adding |
@russtoku What were you doing when you got that error? Can you try it with the 0.9 image and the updated docker compose file. I'm okay with sticking with the Using containers takes a little change in your workflow but it's possible to work locally using containers without issues. PyCharm and VScode both allow for editing and hotloading code into a container and I've personally debugged multithreaded c++ servers running on containers with the ability to step through functions, update variables and even disassemble code. You can edit code locally and see changes run on a container with fairly minimal chantges to your workflow. |
After running This is a different error from my previous attempt. In both cases, after cloning the repo and checking out you PR/83 branch, I run the The first try used This second try indicates that the migrations weren't run to initialze the database before the Django dev server was started. This would suggest that the sequencing of steps are not quite there yet. Here's the output from the dev server container:
|
I'm personally OK with whatever is decided; even removing |
@russtoku The error you're getting is probably due to the migrations not being applied. The migrations get applied before the django container runs so you shouldn't see that. Can you post the full output of the docker-compose up invocation? |
Sorry, I don’t have access to my Macbook Air for three weeks. |
With commit
|
Add updates to allow docker-compose with dev configs to work