Skip to content

Commit 4b2207b

Browse files
authored
Merge pull request #18 from uklibraries/fix-build
Fix build
2 parents bfa3a1b + f285495 commit 4b2207b

File tree

8 files changed

+54
-64
lines changed

8 files changed

+54
-64
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dockerfile
99
docker-compose.yml
1010
README.md
1111
LICENSE.txt
12+
public/cache

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: docker compose logs
4747

4848
- name: Run linting inside app container
49-
run: docker compose run --rm -T findingaid /vendor/bin/phpcs -w --exclude=Generic.Files.LineLength --standard=PSR12 /tests /app
49+
run: docker compose run --rm -T findingaid /opt/findingaid/vendor/bin/phpcs -w --exclude=Generic.Files.LineLength --standard=PSR12 /opt/findingaid/tests /opt/findingaid/app
5050

5151
- name: Teardown
5252
if: always()
@@ -72,7 +72,7 @@ jobs:
7272
run: docker compose logs
7373

7474
- name: Run tests inside app container
75-
run: docker compose run --rm -T findingaid /vendor/bin/phpunit -c /phpunit.xml /tests
75+
run: docker compose run --rm -T findingaid /opt/findingaid/vendor/bin/phpunit -c /opt/findingaid/phpunit.xml /opt/findingaid/tests
7676

7777
- name: Teardown
7878
if: always()

Dockerfile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ RUN apk add --no-cache \
1919
COPY --from=composer:2.8 /usr/bin/composer /usr/bin/composer
2020
COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
2121

22-
WORKDIR /
22+
WORKDIR /opt/findingaid
2323

2424
COPY ./composer.json .
2525
COPY ./composer.lock .
2626

2727
RUN composer install --no-interaction
2828

29-
COPY exe/build.sh /exe/build.sh
29+
COPY /exe ./exe
3030

3131
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
3232
RUN chmod +x /usr/local/bin/entrypoint.sh
@@ -49,10 +49,6 @@ COPY ./composer.lock .
4949

5050
RUN composer install --no-interaction --no-dev
5151

52-
WORKDIR /app
53-
54-
COPY ./app .
55-
5652
FROM php:8.3-fpm-alpine AS ci
5753

5854
RUN apk add --no-cache \
@@ -62,11 +58,11 @@ RUN apk add --no-cache \
6258
WORKDIR /app
6359

6460
COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
65-
COPY --from=prod-builder /app .
66-
COPY --from=development /vendor /vendor
67-
COPY ./phpunit.xml /phpunit.xml
61+
COPY --from=development /opt/findingaid/vendor /opt/findingaid/vendor
62+
COPY ./phpunit.xml /opt/findingaid/phpunit.xml
63+
COPY /app .
6864

69-
COPY exe/build.sh /exe/build.sh
65+
COPY exe/build.sh /opt/findingaid/exe/build.sh
7066
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
7167
RUN chmod +x /usr/local/bin/entrypoint.sh
7268

@@ -76,15 +72,24 @@ CMD ["php-fpm", "-F"]
7672

7773
FROM php:8.3-fpm-alpine AS production
7874

79-
WORKDIR /app
75+
RUN apk add --no-cache \
76+
libzip-dev \
77+
bash
78+
79+
COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
80+
COPY --from=prod-builder /composer/vendor /opt/findingaid/vendor
8081

81-
COPY --from=prod-builder /app .
82-
COPY --from=prod-builder /composer/vendor /vendor
82+
WORKDIR /opt/findingaid
83+
84+
COPY ./app ./app
85+
COPY ./public ./public
86+
COPY ./exe ./exe
8387

84-
COPY exe/build.sh /exe/build.sh
8588
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
8689
RUN chmod +x /usr/local/bin/entrypoint.sh
8790

91+
RUN ./exe/build.sh
92+
8893
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
8994
EXPOSE 9000
9095
CMD ["php-fpm", "-F"]

docker-compose.ci.override.yml

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,6 @@ services:
22
findingaid:
33
build:
44
context: .
5-
target: CI
6-
volumes:
7-
- ./app:/app
8-
- ./public:/public
9-
- cache:/public/cache
10-
- ./xml:/xml
11-
- vendor:/vendor
12-
- ./tests:/tests
13-
networks:
14-
- app_net
15-
16-
web:
17-
image: nginx:1.29.0
18-
ports:
19-
- 8080:80
20-
volumes:
21-
- ./app:/app
22-
- ./public:/public
23-
- cache:/public/cache
24-
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
25-
networks:
26-
- app_net
27-
depends_on:
28-
- findingaid
29-
30-
networks:
31-
app_net:
32-
driver: bridge
33-
34-
volumes:
35-
vendor:
36-
cache:
5+
target: ci
6+
environment:
7+
APP_ENV: ci

docker-compose.dev.override.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
findingaid:
3+
build:
4+
target: development
5+
environment:
6+
APP_ENV: development
7+
develop:
8+
watch:
9+
- action: restart
10+
path: ./app/assets/js
11+
target: /opt/findingaid/app/assets/js

docker-compose.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ services:
22
findingaid:
33
build:
44
context: .
5-
target: development
65
volumes:
7-
- ./app:/app
8-
- ./public:/public
9-
- cache:/public/cache
10-
- ./xml:/xml
11-
- vendor:/vendor
6+
- ./app:/opt/findingaid/app
7+
- ./public:/opt/findingaid/public
8+
- ./xml:/opt/findingaid/xml
9+
- ./tests:/opt/findingaid/tests
10+
- ./phpunit.xml:/opt/findingaid/phpunit.xml
1211
networks:
1312
- app_net
1413

@@ -17,19 +16,18 @@ services:
1716
ports:
1817
- 8080:80
1918
volumes:
20-
- ./app:/app
21-
- ./public:/public
22-
- cache:/public/cache
19+
- ./app:/opt/findingaid/app
20+
- ./public:/opt/findingaid/public
2321
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
2422
networks:
2523
- app_net
2624
depends_on:
2725
- findingaid
2826

27+
volumes:
28+
app:
29+
public:
30+
2931
networks:
3032
app_net:
3133
driver: bridge
32-
33-
volumes:
34-
vendor:
35-
cache:

entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
set -eu
3-
PUBLIC_DIR="/public"
3+
PUBLIC_DIR="/opt/findingaid/public"
44
CACHE_DIR="$PUBLIC_DIR/cache"
55

66
chmod 755 "$PUBLIC_DIR"
@@ -11,6 +11,10 @@ chown -R www-data:www-data "$CACHE_DIR"
1111
find "$CACHE_DIR" -type d -exec chmod 2775 "{}" \;
1212
find "$CACHE_DIR" -type f -exec chmod 0664 "{}" \;
1313

14-
bash /exe/build.sh
14+
# APP_ENV set in compose file
15+
if [ "${APP_ENV:-}" = "development" ]; then
16+
echo "Building js for dev"
17+
bash /opt/findingaid/exe/build.sh
18+
fi
1519

1620
exec "$@"

nginx/default.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ server {
22
listen 80;
33
server_name localhost;
44

5-
root /public;
5+
root /opt/findingaid/public;
66
index index.php;
77

88
location / {

0 commit comments

Comments
 (0)