-
Notifications
You must be signed in to change notification settings - Fork 4
Ahoy containers #15
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
Merged
Merged
Ahoy containers #15
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
84e6e45
feat: Sets-up first version of docker and docker compose ymls
ruiconti 61c10ec
refactor: Centers ORM business under ORM module
ruiconti 34c9131
refactor: Changes Makefile to use docker commands
ruiconti 60999d9
refactor: Minor changes in migrations
ruiconti 291a4ab
feat: Improve user security on container process
ruiconti 7c29a7c
feat: Extends commands available to Makefile
ruiconti 2ef4d6d
feat: Passes Dockerfile args
ruiconti 6182867
chore: Makes'em executables
ruiconti e6326f4
Merge branch 'main' into 8-ahoy-containers
ruiconti e748feb
refactor: clean now properly kills and rms containers
ruiconti f61a37e
refactor: Changes containers names and persist db volume
ruiconti f68d516
refactor: Exposes PROJECT_NAME variable to child processes
ruiconti 204a7e3
fix: Fixes permission setting on container
ruiconti 034e146
chore: Properly kills and removes pg container after tests
ruiconti 1cac9c4
doc: Includes docker instructions
ruiconti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM python:3.8.8-slim-buster | ||
|
||
|
||
ARG PROJECT_NAME=${PROJECT_NAME:-kps} | ||
ARG HOST_UID=${HOST_UID:-9000} | ||
ARG HOST_USER=${HOST_USER:-app} | ||
|
||
ENV HOST_HOME=/home/$HOST_USER | ||
ENV APP_DIR=$HOST_HOME/$PROJECT_NAME | ||
ENV PATH $HOST_HOME/.local/bin:$PATH | ||
|
||
# Create a user specifically for app running | ||
# Sets them with enough permissions in its home dir | ||
RUN adduser --home $HOST_HOME --uid $HOST_UID $HOST_USER --quiet --system --group \ | ||
&& chown -R $HOST_UID:$HOST_UID $HOST_HOME/ \ | ||
&& chmod -R 770 $HOST_HOME \ | ||
&& chmod g+s $HOST_HOME | ||
|
||
# Switches to created user | ||
USER $HOST_UID | ||
|
||
# Creates an app dir | ||
RUN mkdir $APP_DIR | ||
WORKDIR $APP_DIR | ||
|
||
# Copies and installs requirements | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Finishes copying code | ||
COPY . . | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["sh", "docker/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "3.9" | ||
|
||
x-common-variables: &common-variables | ||
POSTGRES_USER: ${POSTGRES_USER:-postgres} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} | ||
POSTGRES_DB: ${POSTGRES_DB:-template} | ||
|
||
services: | ||
dbpg: | ||
container_name: ${PROJECT_NAME}_postgres | ||
image: postgres | ||
environment: | ||
<<: *common-variables | ||
PGDATA: /data/postgres | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- ./db-pgdata:/var/lib/postgresql/data/pgdata | ||
networks: | ||
- backend | ||
restart: unless-stopped | ||
|
||
web: | ||
environment: | ||
<<: *common-variables | ||
POSTGRES_HOST: dbpg | ||
MAX_CONCURRENCY: 1 | ||
HOST: "0.0.0.0" | ||
PORT: "5000" | ||
container_name: ${PROJECT_NAME}_web | ||
image: kms:test | ||
build: | ||
context: . | ||
args: | ||
- HOST_UID=${HOST_UID:-9000} | ||
- HOST_USER=${HOST_USER:-app} | ||
ports: | ||
- "5000:5000" | ||
depends_on: | ||
- dbpg | ||
volumes: | ||
- ./:/app | ||
networks: | ||
- backend | ||
restart: unless-stopped | ||
|
||
ruiconti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
networks: | ||
backend: | ||
driver: bridge | ||
|
||
volumes: | ||
db-pgdata: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
sh docker/uvicorn.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
CREATE USER tester; | ||
CREATE DATABASE court; | ||
GRANT ALL PRIVILEGES ON DATABASE court TO tester; | ||
EOSQL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alembic -x data=true downgrade base | ||
alembic -x data=true upgrade head |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bash/sh | ||
sh docker/migration.sh | ||
pytest --color=yes --showlocals --tb=short -v tests/auth/unit | ||
pytest --color=yes --showlocals --tb=short -v tests/auth/integration | ||
pytest --color=yes --showlocals --tb=short -v tests/auth/e2e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uvicorn src.server.app:app --port $PORT --host $HOST --loop uvloop --log-level info --workers $MAX_CONCURRENCY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.