-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from chnm/feature/dockerize
Merge feature/dockerize into main
- Loading branch information
Showing
6 changed files
with
228 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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,56 @@ | ||
FROM rust as volta-build | ||
WORKDIR /src | ||
RUN git clone https://github.com/volta-cli/volta.git /src | ||
RUN cargo build | ||
RUN ls /src/target/debug | ||
|
||
# Pull base image for Python 3.11 | ||
FROM python:3.11 | ||
|
||
# Set environment variables | ||
ENV PIP_DISABLE_PIP_VERSION_CHECK 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy project | ||
COPY . /app/ | ||
|
||
# Install dependencies with Poetry | ||
RUN pip3 install poetry | ||
|
||
RUN poetry config virtualenvs.create false | ||
RUN poetry install --no-root | ||
|
||
# Copy over Volta binaries | ||
RUN mkdir -p /root/.volta/bin | ||
COPY --from=volta-build /src/target/debug/volta /root/.volta/bin | ||
COPY --from=volta-build /src/target/debug/volta-migrate /root/.volta/bin | ||
COPY --from=volta-build /src/target/debug/volta-shim /root/.volta/bin | ||
|
||
# shell stuff for volta | ||
SHELL ["/bin/bash", "-c"] | ||
ENV BASH_ENV ~/.bashrc | ||
ENV VOLTA_HOME /root/.volta | ||
ENV PATH $VOLTA_HOME/bin:$PATH | ||
|
||
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/node | ||
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/npm | ||
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/npx | ||
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/pnpm | ||
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/yarn | ||
|
||
# triggers node installation | ||
RUN node -v && npm -v | ||
RUN npm install | ||
|
||
# generate front end assets | ||
RUN poetry run python manage.py tailwind install | ||
RUN poetry run python manage.py tailwind build | ||
RUN poetry run python manage.py collectstatic --no-input | ||
|
||
# clean up | ||
RUN rm -rf /root/.volta | ||
RUN rm -rf /app/node_modules |
This file contains 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 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,45 @@ | ||
--- | ||
name: graffitihouse | ||
|
||
services: | ||
app: | ||
build: . | ||
image: "rrchnm/graffitihouse" | ||
ports: | ||
- 8000:8000 | ||
volumes: | ||
- dj-data:/app | ||
environment: | ||
- DEBUG=True | ||
- DJANGO_SECRET_KEY=thisisnotasecretkey | ||
- DJANGO_ALLOWED_HOSTS=localhost | ||
- DJANGO_CSRF_TRUSTED_ORIGINS=http://localhost | ||
- DB_HOST=db | ||
- DB_PORT=5432 | ||
- DB_NAME=graffitihouse | ||
- DB_USER=graffitihouse | ||
- DB_PASSWORD=password | ||
command: > | ||
sh -c "poetry run python3 manage.py migrate && | ||
poetry run python3 manage.py runserver 0.0.0.0:8000" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
db: | ||
image: postgres:16 | ||
volumes: | ||
- pg-data:/var/lib/postgresql/data | ||
environment: | ||
- POSTGRES_DB=graffitihouse | ||
- POSTGRES_USER=graffitihouse | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_HOST=db | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U graffitihouse"] | ||
interval: 2s | ||
timeout: 5s | ||
retries: 3 | ||
|
||
volumes: | ||
pg-data: | ||
dj-data: |
This file contains 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,84 @@ | ||
# this is a Jinja2 template file used during the Ansible deployment | ||
# environment specific configuration can be found in our Ansble scripts | ||
--- | ||
name: {{ compose_stack_name }} | ||
|
||
services: | ||
|
||
{% set service = 'app' %} | ||
|
||
app: | ||
image: ghcr.io/{{ template.git.package.image_name }}:{{ template.git.package.tag }} | ||
restart: unless-stopped | ||
ports: | ||
- "{{ template.env.host_app_port }}:8000" | ||
environment: | ||
- DEBUG={{ template.env.debug_flag }} | ||
- DJANGO_SECRET_KEY={{ template.env.secret_key }} | ||
- DJANGO_ALLOWED_HOSTS={{ template.env.allowed_hosts }} | ||
- DJANGO_CSRF_TRUSTED_ORIGINS={{ template.env.trusted_origins }} | ||
- DB_HOST=db | ||
- DB_PORT={{ template.env.host_db_port }} | ||
- DB_NAME={{ template.env.db_name }} | ||
- DB_USER={{ template.env.db_user }} | ||
- DB_PASS={{ template.env.db_pass }} | ||
- OBJ_STORAGE={{ template.env.obj_storage }} | ||
- OBJ_STORAGE_ACCESS_KEY_ID={{ template.env.obj_storage_access_key_id }} | ||
- OBJ_STORAGE_SECRET_ACCESS_KEY={{ template.env.obj_storage_secret_access_key }} | ||
- OBJ_STORAGE_BUCKET_NAME={{ template.env.obj_storage_bucket_name }} | ||
- OBJ_STORAGE_ENDPOINT_URL={{ template.env.obj_storage_endpoint_url }} | ||
command: > | ||
sh -c "poetry run python3 manage.py migrate && | ||
poetry run python3 manage.py runserver 0.0.0.0:8000" | ||
{% if template.volumes is defined %} | ||
{% set vols = (template.volumes | selectattr('service', 'eq', service)) %} | ||
{% if vols is iterable and vols | length > 0 %} | ||
|
||
volumes: | ||
{% for vol in vols %} | ||
|
||
- {{ vol.name }}:{{ vol.container_path }} | ||
{% endfor %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
depends_on: | ||
db: | ||
condition: service_healthy | ||
|
||
{% set service = 'db' %} | ||
|
||
db: | ||
image: postgres:12 | ||
restart: unless-stopped | ||
environment: | ||
- POSTGRES_DB={{ template.env.db_name }} | ||
- POSTGRES_USER={{ template.env.db_user }} | ||
- POSTGRES_PASSWORD={{ template.env.db_pass }} | ||
- POSTGRES_HOST=db | ||
{% if template.volumes is defined %} | ||
{% set vols = (template.volumes | selectattr('service', 'eq', service)) %} | ||
{% if vols is iterable and vols | length > 0 %} | ||
|
||
volumes: | ||
{% for vol in vols %} | ||
|
||
- {{ vol.name }}:{{ vol.container_path }} | ||
{% endfor %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U {{ template.env.db_user }}"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
# external volumes managed and defined by ansible | ||
volumes: | ||
{% for vol in template.volumes %} | ||
|
||
{{ vol.name }}: | ||
name: "{{ compose_stack_name }}--{{ vol.name }}" | ||
external: true | ||
{% endfor %} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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