Skip to content

Commit 3fa838d

Browse files
authored
feat: improve Docker image build and compose (#512)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent a0c309d commit 3fa838d

File tree

4 files changed

+35
-51
lines changed

4 files changed

+35
-51
lines changed

.dockerignore

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,24 @@
1-
**/.*
2-
**/.git
3-
**/.gitignore
4-
**/.github
5-
**/.vscode
6-
**/.idea
7-
**/coverage
8-
**/.aws
9-
**/.ssh
10-
**/.DS_Store
11-
**/.aof
12-
**/venv
13-
**/.venv
14-
**/env
15-
**/bin
16-
# **/docs we want to keep dje/templates/rest_framework/docs/
17-
docs/
18-
# **/dist we want to keep ./thirdparty/dist/
19-
# **/etc we need to keep ./etc/
20-
**/lib
21-
**/include
22-
**/share
23-
**/var
24-
**/*.egg-info
25-
**/*.log
26-
**/__pycache__
27-
**/.*cache
28-
*.pyc
29-
.dockerignore
30-
.readthedocs.yaml
31-
docker.env
32-
.env
33-
Makefile
34-
Dockerfile
35-
README.rst
36-
CHANGELOG.rst
37-
CONTRIBUTING.rst
38-
MANIFEST.in
39-
docker-compose.yml
40-
pyvenv.cfg
1+
# Ignore everything
2+
*
3+
4+
# Allow only what the build needs
5+
!aboutcode/
6+
!component_catalog/
7+
!data/
8+
!dejacode/
9+
!dejacode_toolkit/
10+
!dje/
11+
!license_library/
12+
!notification/
13+
!organization/
14+
!policy/
15+
!product_portfolio/
16+
!purldb/
17+
!reporting/
18+
!thirdparty/
19+
!vulnerabilities/
20+
!workflow/
21+
!LICENSE
22+
!manage.py
23+
!NOTICE
24+
!pyproject.toml

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ ENV VENV_LOCATION=/opt/$APP_NAME/.venv
2727
ENV PYTHONUNBUFFERED=1
2828
# Do not write Python .pyc files
2929
ENV PYTHONDONTWRITEBYTECODE=1
30-
# Add the app dir in the Python path for entry points availability
31-
ENV PYTHONPATH=$PYTHONPATH:$APP_DIR
30+
# Set the app dir in the Python path for entry points availability
31+
ENV PYTHONPATH=$APP_DIR
3232

3333
# OS requirements
3434
RUN apt-get update \

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ DB_CONTAINER_NAME=db
2525
DB_INIT_FILE=./data/postgresql/initdb.sql.gz
2626
POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
2727
TIMESTAMP=$(shell date +"%Y-%m-%d_%H%M")
28+
IMAGE_NAME=dejacode
2829

2930
# Use sudo for postgres, only on Linux
3031
UNAME := $(shell uname)
@@ -156,11 +157,11 @@ docs:
156157
@${ACTIVATE} sphinx-build -b html ${DOCS_LOCATION} ${DOCS_LOCATION}/_build/html/
157158

158159
build:
159-
@echo "-> Build the Docker images"
160-
${DOCKER_COMPOSE} build
160+
@echo "-> Build the Docker image"
161+
docker build -t $(IMAGE_NAME) .
161162

162163
bash:
163-
${DOCKER_EXEC} web bash
164+
docker run -it $(IMAGE_NAME) bash
164165

165166
shell:
166167
${DOCKER_EXEC} web ./manage.py shell

docker-compose.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
name: dejacode
12
services:
23
db:
3-
image: postgres:16
4+
image: docker.io/library/postgres:16.13
45
env_file:
56
- docker.env
67
volumes:
@@ -15,7 +16,7 @@ services:
1516
retries: 5
1617

1718
redis:
18-
image: redis:alpine
19+
image: docker.io/library/redis:8.6-alpine
1920
# Enable redis data persistence using the "Append Only File" with the
2021
# default policy of fsync every second. See https://redis.io/topics/persistence
2122
command: redis-server --appendonly yes
@@ -78,7 +79,7 @@ services:
7879
- web
7980

8081
nginx:
81-
image: nginx:alpine
82+
image: docker.io/library/nginx:1.29-alpine
8283
ports:
8384
- "${NGINX_PUBLISHED_HTTP_PORT:-80}:80"
8485
- "${NGINX_PUBLISHED_HTTPS_PORT:-443}:443"
@@ -91,12 +92,10 @@ services:
9192
restart: always
9293

9394
clamav:
94-
image: clamav/clamav
95+
image: docker.io/clamav/clamav:1.5_base
9596
volumes:
9697
- clamav_data:/var/lib/clamav
9798
- media:/var/dejacode/media
98-
ports:
99-
- "3310:3310"
10099
restart: always
101100

102101
volumes:

0 commit comments

Comments
 (0)