-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (77 loc) · 3.3 KB
/
Copy pathDockerfile
File metadata and controls
94 lines (77 loc) · 3.3 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM yiisoftware/yii2-php:8.4-fpm-nginx
ARG BUILD_NO_INSTALL
# Install Node.js from official binaries (avoiding NodeSource GPG/SHA1 issues)
ENV NODE_VERSION=20.18.1
RUN ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; \
elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \
else echo "Unsupported architecture: $ARCH" && exit 1; fi && \
curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz" \
| tar -xJf - -C /usr/local --strip-components=1 && \
npm install -g yarn
RUN apt-get update \
&& apt-get install -y $PHPIZE_DEPS \
ssh \
default-mysql-client \
cron \
procps # recommended for dmstr/yii2-resque-module \
&& apt-get remove -y $PHPIZE_DEPS \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN install-php-extensions \
mailparse \
ftp
ENV SUPERVISOR_START_CRON=true \
SUPERVISOR_START_WORKER=true \
SUPERVISOR_START_EXPORT_ENV=true \
SUPERVISOR_WORKER_CMD_OPTS=""
# System files
COPY ./image-files /
RUN chmod +x /usr/local/bin/create-npm-asset-symlinks
# Application packages
WORKDIR /app
COPY src/composer.* /app/src/
COPY src/assets-replaced /app/src/assets-replaced
# Composer installation (skipped on first build in dist-upgrade)
# First install merge-plugin, then install with plugins enabled
# create bc link if not exists
RUN if [ -z "$BUILD_NO_INSTALL" ]; then \
composer -dsrc install --no-dev --prefer-dist --optimize-autoloader && \
composer -dsrc clear-cache && \
ln -s bower-asset /app/vendor/bower && \
ln -s npm-asset /app/vendor/npm; \
fi
# Yarn and Bower packages for frontend assets
COPY src/package.json src/yarn.lock src/.yarnrc src/bower.json src/.bowerrc /app/src/
RUN if [ -z "$BUILD_NO_INSTALL" ] && [ -f /app/src/package.json ]; then \
cd /app/src && \
yarn install --production && \
npx bower install --allow-root --force && \
yarn cache clean; \
fi
# Application source-code
ENV PATH=/app/src/bin:$PATH
COPY ./web /app/web/
COPY ./src /app/src/
COPY ./config /app/config/
COPY ./migrations /app/migrations/
RUN test -f /app/yii || ln -s /app/src/bin/yii /app/yii
# Permissions
RUN mkdir -p runtime web/assets web/bundles /mnt/storage && \
chmod -R 775 runtime web/assets web/bundles /mnt/storage && \
chmod a+x /usr/local/bin/unique-number.sh /usr/local/bin/export-env.sh /usr/local/bin/nodepkg-linuxstatic && \
chmod -R u+x /etc/periodic && \
chown -R www-data:www-data runtime web/assets web/bundles /mnt/storage
VOLUME /app/runtime /app/web/assets /mnt/storage
# Build assets (skipped on first build in dist-upgrade)
RUN if [ -z "$BUILD_NO_INSTALL" ]; then \
PHP_USER_ID=0 APP_NO_CACHE=1 APP_LANGUAGES=en APP_USER_FROM_EMAIL=build@Dockerfile APP_ADMIN_EMAIL=build@Dockerfile yii asset/compress config/assets.php web/bundles/config.php; \
fi
# Install crontab from application config
RUN crontab config/crontab
# export container environment for cronjobs on container start
CMD supervisord -c /etc/supervisor/supervisord.conf
# Tests source-code for integration tests in derived images
COPY ./tests /app/tests
HEALTHCHECK --interval=30s --timeout=5s --start-period=1m \
CMD curl -f http://localhost/static/status.php || exit 1