Skip to content
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

Containerize Hush Line #346

Merged
merged 10 commits into from
May 21, 2024
Merged

Containerize Hush Line #346

merged 10 commits into from
May 21, 2024

Conversation

micahflee
Copy link
Collaborator

This containerizes Hush Line.

Follow the new DEV.md instructions to try it out: https://github.com/micahflee/hushline/blob/containerize/docs/DEV.md

The dev instructions are now the same for all platforms since it's all just running in Docker. Ultimately, the container runs python:3.12-bookworm.

Running make dev starts Hush Line in a container. You can see output from the container in that window, and press ctrl-c to quit. The rest of the Makefile commands (like make test, etc.) require the main container to be running to work, and they also do everything in the container.

There's now a folder called volumes. After you start the server, volumes/app/hushline.db will get created (this file isn't track in git). This way you can access the sqlite3 database outside of docker if you need to.

Another big change is database migrations. There were two identical migrations which was causing it all to break, so I deleted one of them. And now, migrations run automatically when starting the server, so you don't have to make a separate migration step. You just add migrations and restart the server, and the db should be migrated.

Now that it's dockerized, actually running this in production needs to change a bit. The simplest way is to run in prod with docker-compose (on a cloud VM or a Raspberry Pi, or whatever), but it will require making a new docker-compose.yaml file with SECRET_KEY and ENCRYPTION_KEY, and possibly other settings changed.

@glenn-sorrentino please test this out and make sure you're able to get it working locally, and also continue development on top of it. It would be good to get this merged first before I continue other work -- like migrating from sqlite3 to postgres, which would be easier to host going forward.

@glenn-sorrentino
Copy link
Contributor

I stopped the container, started it again, and got "An internal server error occurred", though was working the first time running make dev.

glennsorrentino@m1 hushline-micah % make dev
docker-compose up --build
[+] Building 0.5s (13/13) FINISHED                                                                       docker:desktop-linux
 => [app internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 761B                                                                                     0.0s
 => [app internal] load metadata for docker.io/library/python:3.12-bookworm                                              0.4s
 => [app internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                          0.0s
 => [app 1/8] FROM docker.io/library/python:3.12-bookworm@sha256:25dee7f137aa44c4962d21346385737eb81954b6f06f519fcc348b  0.0s
 => [app internal] load build context                                                                                    0.0s
 => => transferring context: 33.19kB                                                                                     0.0s
 => CACHED [app 2/8] WORKDIR /app                                                                                        0.0s
 => CACHED [app 3/8] RUN apt-get update &&     apt-get upgrade -y &&     apt-get install -y --no-install-recommends      0.0s
 => CACHED [app 4/8] RUN pip install poetry                                                                              0.0s
 => CACHED [app 5/8] RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y                         0.0s
 => CACHED [app 6/8] COPY poetry.lock pyproject.toml /app/                                                               0.0s
 => CACHED [app 7/8] RUN poetry install                                                                                  0.0s
 => CACHED [app 8/8] COPY . /app                                                                                         0.0s
 => [app] exporting to image                                                                                             0.0s
 => => exporting layers                                                                                                  0.0s
 => => writing image sha256:553feb00da7304d2c425a309cc37ffaa2f8a8422982a1b99c01e82dae574707a                             0.0s
 => => naming to docker.io/library/hushline-micah-app                                                                    0.0s
[+] Running 1/2
 ✔ Network hushline-micah_default  Created                                                                               0.0s 
 ⠋ Container hushline-micah-app-1  Created                                                                               0.0s 
Attaching to app-1
app-1  | INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
app-1  | INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
app-1  |  * Serving Flask app 'hushline/__init__.py'
app-1  |  * Debug mode: off
app-1  | INFO  [werkzeug] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
app-1  |  * Running on all addresses (0.0.0.0)
app-1  |  * Running on http://127.0.0.1:5000
app-1  |  * Running on http://172.23.0.2:5000
app-1  | INFO  [werkzeug] Press CTRL+C to quit
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:34:12] "GET / HTTP/1.1" 302 -
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:34:13] "GET /directory HTTP/1.1" 500 -
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:34:13] "GET /favicon.ico HTTP/1.1" 302 -
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:35:52] "GET / HTTP/1.1" 302 -
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:35:52] "GET /directory HTTP/1.1" 500 -
app-1  | INFO  [werkzeug] 192.168.65.1 - - [15/May/2024 23:35:52] "GET /favicon.ico HTTP/1.1" 302 -

@glenn-sorrentino glenn-sorrentino merged commit 4e6b925 into scidsg:main May 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants