Skip to content

Commit 2d87edd

Browse files
authored
Fix Dockerfile not using current sources (#60)
The Dockerfile previously cloned the LNT sources as a RUN step, which meant that when rebuilding the image any changes to the LNT sources wouldn't be picked up because it would be cached. This PR fixes it alongside some other things: - Don't clone the sources in a RUN step, instead COPY them from the build context - Move the Dockerfile/docker-compose.yml files to the root so the source files are in the build directory - Split out the install step so that we only COPY over the files necessary to run the install (to aid with layer caching) - In the docker-compose.yml file, postgres:11 doesn't seem to exist anymore on docker.hub so upgrade it to 13, and fully qualify it so it can be used by podman - Remove the .env file and just write the defaults directly in the docker-compose.yml file - This also downgrades Jinja2 and pyyaml again to get building with Python 3.10, but these can probably be fixed in another PR
1 parent 8b17183 commit 2d87edd

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM python:3.10-alpine
2+
3+
RUN apk update \
4+
&& apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \
5+
&& apk add --no-cache libpq
6+
7+
WORKDIR /var/src/lnt
8+
9+
COPY requirements.server.txt setup.py .
10+
# setup.py uses lnt.__version__ etc.
11+
COPY lnt/__init__.py lnt/__init__.py
12+
# we build the cperf extension during install
13+
COPY lnt/testing/profile lnt/testing/profile
14+
15+
RUN pip3 install -r requirements.server.txt \
16+
&& apk --purge del .build-deps \
17+
&& mkdir /var/log/lnt
18+
19+
COPY . .
20+
COPY docker/docker-entrypoint.sh docker/wait_db /usr/local/bin/
21+
22+
VOLUME /var/log
23+
24+
EXPOSE 8000
25+
26+
ENV DB_ENGINE= DB_HOST= DB_USER= DB_PWD= DB_BASE=
27+
28+
ENTRYPOINT docker-entrypoint.sh

docker/docker-compose.yml renamed to docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ services:
2121

2222
db:
2323
container_name: lnt-postgres
24-
image: postgres:11-alpine
24+
image: docker.io/postgres:13-alpine
2525
environment:
2626
- POSTGRES_PASSWORD=${DB_PWD}
27-
- POSTGRES_USER=${DB_USER}
28-
- POSTGRES_DB=${DB_BASE}
27+
- POSTGRES_USER=${DB_USER:-lntuser}
28+
- POSTGRES_DB=${DB_BASE:-lnt}

docker/.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

requirements.server.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
.
33
psycopg2==2.9.10
44
gunicorn==19.9.0
5-
Jinja2==3.1.6
5+
Jinja2==2.11.3
66
progressbar2
7-
pyyaml==6.0
7+
pyyaml==5.1.2

0 commit comments

Comments
 (0)