Improve nixified Dockerfile, adjust docker-compose yamls

labelmaker-in-tree
Stan Drozd 2021-03-07 03:30:08 +01:00
parent 9a7c2271e7
commit cb6eec3c9f
No known key found for this signature in database
GPG Key ID: E96EA51A5D7F84E7
5 changed files with 43 additions and 15 deletions

View File

@ -1,5 +1,5 @@
# syntax = docker/dockerfile:1.2
FROM nixos/nix
FROM nixos/nix as nix-base
ENV PYTHONUNBUFFERED 1
RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs && \
@ -7,19 +7,33 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs && \
WORKDIR /code
RUN wget https://github.com/vishnubob/wait-for-it/raw/8ed92e8cab83cfed76ff012ed4a36cef74b28096/wait-for-it.sh -O /usr/local/bin/wait-for-it && chmod +x /usr/local/bin/wait-for-it
RUN wget https://github.com/vishnubob/wait-for-it/raw/8ed92e8cab83cfed76ff012ed4a36cef74b28096/wait-for-it.sh -O /usr/local/bin/wait-for-it.sh && chmod +x /usr/local/bin/wait-for-it.sh
RUN nix-env -iA nixpkgs.git nixpkgs.bash
RUN nix-env -iA nixpkgs.git nixpkgs.bash nixpkgs.coreutils
ADD ./pyproject.toml .
ADD ./poetry.lock .
ADD ./nix ./nix
ADD ./*.nix .
ADD ./labelmaker/*.nix ./labelmaker/
ADD ./nix ./nix
ADD ./labelmaker/Gemfile* ./labelmaker/
ADD ./poetry.lock .
ADD ./pyproject.toml .
RUN nix-shell
FROM nix-base as nix-cached
RUN touch spejstore.py
RUN nix build -L
RUN rm spejstore.py
ADD . .
RUN nix-build -A manage-py
CMD bash -c "nix-build -A manage-py && result/bin/managePy migrate && result/bin/managePy createsuperuser && result/bin/managePy runserver 0.0.0.0:8000"
FROM nix-cached as spejstore
RUN nix-env -if . -A manage-py
CMD /usr/local/bin/wait-for-it.sh db:5432 && manage-py migrate && \
manage-py createsuperuser && \
manage-py runserver 0.0.0.0:8000
FROM nix-cached as labelmaker
RUN nix-env -if . -A labelmaker
CMD labelmaker

View File

@ -12,7 +12,7 @@ let
projectDir = src;
};
dep-env = poetry-app.dependencyEnv;
manage-py = pkgs.writeScriptBin "managePy" ''
manage-py = pkgs.writeScriptBin "manage-py" ''
cd ${src}
${dep-env}/bin/python manage.py $@
'';

View File

@ -1,6 +1,9 @@
version: "3"
version: "3.4"
services:
web:
environment:
- SPEJSTORE_ENV=dev
- SPEJSTORE_ALLOWED_HOSTS=localhost,127.0.0.1
- SPEJSTORE_ALLOWED_HOSTS=web,localhost,127.0.0.1
labelmaker:
environment:
- SPEJSTORE_BASE_URL=http://web:8000/api/1/

View File

@ -1,4 +1,4 @@
version: "3"
version: "3.4"
services:
db:

View File

@ -1,15 +1,15 @@
version: "3"
version: "3.4"
services:
db:
build: postgres-hstore
restart: always
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
web:
build:
context: .
dockerfile: Dockerfile.nixified
target: spejstore
restart: always
volumes:
- .:/code
@ -21,3 +21,14 @@ services:
- SPEJSTORE_CLIENT_ID
- SPEJSTORE_SECRET
- SPEJSTORE_ENV
labelmaker:
build:
context: .
dockerfile: Dockerfile.nixified
target: labelmaker
depends_on:
- web
ports:
- "4567:4567"