Skip to content

Commit 9270402

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] [CONFIG] [Docker] lint stage bugfix:
- new previous "init" stage. Now "base" install dependencies. - "lint" stage fixes.
1 parent af0d465 commit 9270402

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
###############################################################################
2-
FROM python:3.12.4-alpine3.20 AS base
2+
FROM python:3.12.4-alpine3.20 AS init
33

44
ENV WORKDIR=/app
55
WORKDIR ${WORKDIR}
66

77
RUN apk add --update --no-cache make
88

9+
###############################################################################
10+
FROM init AS base
11+
12+
ENV WORKDIR=/app
13+
WORKDIR ${WORKDIR}
14+
15+
COPY ./Makefile ${WORKDIR}/
16+
COPY ./requirements.txt ${WORKDIR}/
17+
RUN make dependencies
18+
919
###############################################################################
1020
FROM base AS lint
1121

@@ -16,7 +26,6 @@ RUN apk add --update --no-cache make nodejs npm
1626
RUN apk add --update --no-cache yamllint
1727

1828
RUN npm install -g --ignore-scripts markdownlint-cli
19-
RUN npm install -g --ignore-scripts pyright
2029

2130
# [!TIP] Use a bind-mount to "/app" to override following "copys"
2231
# for lint and test against "current" sources in this stage
@@ -32,7 +41,7 @@ COPY ./LICENSE.md ${WORKDIR}/
3241
COPY ./CODE_OF_CONDUCT.md ${WORKDIR}/
3342

3443
# Code source
35-
COPY ./src ${WORKDIR}/
44+
COPY ./src/ ${WORKDIR}/src
3645
COPY ./requirements.txt ${WORKDIR}/
3746
COPY ./setup.cfg ${WORKDIR}/
3847
COPY ./Makefile ${WORKDIR}/
@@ -55,12 +64,8 @@ CMD ["make", "lint"]
5564
FROM base AS development
5665

5766
COPY ./Makefile ${WORKDIR}/
58-
COPY ./requirements.txt ${WORKDIR}/
5967
COPY ./setup.cfg ${WORKDIR}/
60-
61-
RUN make dependencies
62-
63-
COPY ./src ${WORKDIR}/src
68+
COPY ./src/ ${WORKDIR}/src
6469

6570
RUN ls -alh
6671

@@ -108,7 +113,7 @@ CMD ["make", "test"]
108113
## in the production phase, "good practices" such as
109114
## WORKDIR and USER are maintained
110115
##
111-
FROM python:3.12.4-alpine3.20 AS production
116+
FROM init AS production
112117

113118
ENV LOG_LEVEL=INFO
114119
ENV BRUTEFORCE=false
@@ -119,7 +124,6 @@ RUN adduser -D worker
119124
RUN mkdir -p /app
120125
RUN chown worker:worker /app
121126

122-
RUN apk add --update --no-cache make
123127
COPY ./Makefile ${WORKDIR}/
124128

125129
COPY --from=builder /app/build/ ${WORKDIR}/

0 commit comments

Comments
 (0)