Fix Dockerfile dependencies

This commit is contained in:
Correl Roush 2022-07-28 00:28:08 -04:00
parent 90aa293169
commit 736a1a07e7
4 changed files with 21 additions and 109 deletions

View file

@ -9,18 +9,21 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.1.4
RUN apk add --no-cache build-base libffi-dev musl-dev openssl-dev rust cargo yajl-dev
RUN apk add --no-cache build-base libffi-dev musl-dev openssl-dev postgresql-dev rust cargo yajl-dev
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN poetry export \
RUN . /venv/bin/activate \
&& poetry export \
--format requirements.txt \
--without-hashes \
| /venv/bin/pip install -r /dev/stdin
| pip install -r /dev/stdin
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
RUN . /venv/bin/activate \
&& poetry build \
&& pip install dist/*.whl
FROM base as frontend
@ -37,12 +40,11 @@ FROM base as final
EXPOSE 8888
ENV TUTOR_PORT=8888 \
TUTOR_DATABASE=/tutor.db \
TUTOR_STATIC=/www
RUN apk add yajl
RUN apk add libpq libstdc++ yajl
COPY --from=builder /venv /venv
COPY --from=frontend /www/public /www
COPY docker-entrypoint.sh tables.sql ./
COPY docker-entrypoint.sh ./
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["server"]

12
poetry.lock generated
View file

@ -249,6 +249,7 @@ optional = false
python-versions = ">=3.6"
[package.dependencies]
psycopg-c = {version = "3.0.15", optional = true, markers = "extra == \"c\""}
tzdata = {version = "*", markers = "sys_platform == \"win32\""}
[package.extras]
@ -259,6 +260,14 @@ docs = ["Sphinx (>=4.2)", "furo (==2021.11.23)", "sphinx-autobuild (>=2021.3.14)
pool = ["psycopg-pool"]
test = ["mypy (>=0.920,!=0.930,!=0.931)", "pproxy (>=2.7)", "pytest (>=6.2.5)", "pytest-asyncio (>=0.16,<0.17)", "pytest-cov (>=3.0)", "pytest-randomly (>=3.10)"]
[[package]]
name = "psycopg-c"
version = "3.0.15"
description = "PostgreSQL database adapter for Python -- C optimisation distribution"
category = "main"
optional = false
python-versions = ">=3.6"
[[package]]
name = "py"
version = "1.11.0"
@ -373,7 +382,7 @@ python-versions = ">=2"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "18ad6c898128ac8185c73e9471a3b665f51b72048c225ca7f4325402f4f80b17"
content-hash = "caaf302d6a55e9ff876fbcf8041aafb8c6b2a68369552e5a2d1aec847fd8251b"
[metadata.files]
anyio = []
@ -425,6 +434,7 @@ pluggy = [
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
]
psycopg = []
psycopg-c = []
py = [
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},

View file

@ -13,7 +13,7 @@ httpx = "^0.18.2"
parsy = "^1.3.0"
jsonslicer = "^0.1.7"
tqdm = "^4.64.0"
psycopg = "^3.0"
psycopg = {extras = ["c"], version = "^3.0"}
[tool.poetry.dev-dependencies]
pytest = "*"

View file

@ -1,100 +0,0 @@
CREATE TABLE IF NOT EXISTS `sets` (
`set_code` TEXT PRIMARY KEY,
`name` TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS `rarities` (
`rarity` TEXT PRIMARY KEY,
`rarity_ord` INTEGER NOT NULL
);
DELETE FROM `rarities`;
INSERT INTO `rarities` (`rarity`, `rarity_ord`) VALUES
('n/a', 0),
('common', 1),
('uncommon', 2),
('rare', 3),
('special', 4),
('mythic', 5),
('bonus', 6);
CREATE TABLE IF NOT EXISTS `cards` (
`scryfall_id` TEXT PRIMARY KEY,
`oracle_id` TEXT,
`name` TEXT NOT NULL,
`set_code` TEXT,
`collector_number` TEXT,
`release_date` TEXT,
`rarity` TEXT NOT NULL,
`color_identity` TEXT NOT NULL,
`cmc` TEXT NOT NULL, -- Decimal value
`type_line` TEXT NOT NULL,
`foil` INTEGER NOT NULL DEFAULT 0,
`nonfoil` INTEGER NOT NULL DEFAULT 1,
`variation` INTEGER NOT NULL DEFAULT 0,
`edhrec_rank` INTEGER,
`oracle_text` TEXT,
FOREIGN KEY (`set_code`) REFERENCES `sets` (`set_code`),
FOREIGN KEY (`rarity`) REFERENCES `rarities` (`rarity`)
);
CREATE INDEX IF NOT EXISTS `cards_name` ON `cards`(`name` COLLATE nocase);
CREATE INDEX IF NOT EXISTS `cards_rarity` ON `cards`(`rarity`);
CREATE INDEX IF NOT EXISTS `cards_color_identity` ON `cards`(`color_identity`);
CREATE INDEX IF NOT EXISTS `cards_oracle_id` ON `cards` (`oracle_id`);
CREATE INDEX IF NOT EXISTS `cards_name` ON `cards` (`name`);
CREATE TABLE IF NOT EXISTS `copies` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`collection` TEXT NOT NULL DEFAULT 'Default',
`scryfall_id` TEXT,
`isFoil` INTEGER NOT NULL DEFAULT 0,
`language` TEXT,
`condition` TEXT,
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `card_prices` (
`scryfall_id` TEXT,
`date` TEXT,
`usd` TEXT, -- Decimal value
`usd_foil` TEXT, -- Decimal value
`eur` TEXT, -- Decimal value
`eur_foil` TEXT, -- Decimal value
`tix` TEXT, -- Decimal value
PRIMARY KEY (`scryfall_id`, `date`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `legalities` (
`scryfall_id` TEXT NOT NULL,
`format` TEXT NOT NULL,
`legality` TEXT NOT NULL,
PRIMARY KEY (`scryfall_id`, `format`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `games` (
`scryfall_id` TEXT NOT NULL,
`game` TEXT NOT NULL, -- 'paper', 'arena', or 'mtgo'
PRIMARY KEY (`scryfall_id`, `game`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `decks` (
`deck_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS `deck_cards` (
`deck_id` INTEGER NOT NULL,
`oracle_id` TEXT NOT NULL,
`quantity` INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY (`deck_id`, `oracle_id`),
FOREIGN KEY (`deck_id`) REFERENCES `decks`(`deck_id`)
);
CREATE TABLE IF NOT EXISTS `vars` (
`key` TEXT PRIMARY KEY,
`value` TEXT
);