-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (41 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
51 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM ubuntu:24.04 AS base
RUN apt-get update \
&& apt-get install -y tesseract-ocr unzip php-cli php-imagick php-xml php-mbstring composer
FROM base AS build
WORKDIR /usr/src/watermeter
# Create necessary directories and set permissions
RUN mkdir -p log/debug log/error tmp \
&& chmod -R 777 log tmp
COPY composer.json ./
RUN composer install --no-ansi --no-interaction --no-progress --no-cache
COPY classes/ ./classes/
COPY public/ ./public/
COPY src/ ./src/
COPY LICENSE README.md ./
FROM build AS test
# Install xdebug
RUN apt install -y php-xdebug
# Copy current source again to ensure it's not cached from build stage if it was already existing
COPY classes/ ./classes/
COPY tests/ ./tests/
# Run Static Analysis
RUN vendor/bin/phpstan analyse --no-progress src classes
# Run Unit Tests
RUN XDEBUG_MODE=coverage vendor/bin/phpunit tests
FROM base AS final
WORKDIR /usr/src/watermeter
COPY composer.json ./
# Do not install dev dependencies on final build
RUN composer install --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress
# Create necessary directories and set permissions
RUN mkdir -p log/debug log/error tmp \
&& chmod -R 777 log tmp
# Copy current source again to ensure it's not cached from build stage if it was already existing
COPY classes/ ./classes/
COPY public/ ./public/
COPY src/ ./src/
COPY LICENSE README.md ./
# Run Smoke Test
RUN php /usr/src/watermeter/public/index.php | grep 1189.3858
WORKDIR /usr/src/watermeter/public
CMD [ "php", "-S", "0.0.0.0:3000" ]