Skip to content

Commit 4e7cad9

Browse files
authored
Merge pull request DSpace#2137 from mark-cooper/dspace-angular-dist
Build & publish dspace/dspace-angular imgs with -dist suffix
2 parents 1ba3a05 + 7410141 commit 4e7cad9

5 files changed

Lines changed: 126 additions & 1 deletion

File tree

.github/workflows/docker.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,33 @@ jobs:
8888
# Use tags / labels provided by 'docker/metadata-action' above
8989
tags: ${{ steps.meta_build.outputs.tags }}
9090
labels: ${{ steps.meta_build.outputs.labels }}
91+
92+
#####################################################
93+
# Build/Push the 'dspace/dspace-angular' image ('-dist' tag)
94+
#####################################################
95+
# https://github.com/docker/metadata-action
96+
# Get Metadata for docker_build_dist step below
97+
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular-dist' image
98+
id: meta_build_dist
99+
uses: docker/metadata-action@v4
100+
with:
101+
images: dspace/dspace-angular
102+
tags: ${{ env.IMAGE_TAGS }}
103+
# As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
104+
# tagging logic as the primary 'dspace/dspace-angular' image above.
105+
flavor: ${{ env.TAGS_FLAVOR }}
106+
suffix=-dist
107+
108+
- name: Build and push 'dspace-angular-dist' image
109+
id: docker_build_dist
110+
uses: docker/build-push-action@v3
111+
with:
112+
context: .
113+
file: ./Dockerfile.dist
114+
platforms: ${{ env.PLATFORMS }}
115+
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
116+
# but we ONLY do an image push to DockerHub if it's NOT a PR
117+
push: ${{ github.event_name != 'pull_request' }}
118+
# Use tags / labels provided by 'docker/metadata-action' above
119+
tags: ${{ steps.meta_build_dist.outputs.tags }}
120+
labels: ${{ steps.meta_build_dist.outputs.labels }}

Dockerfile.dist

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This image will be published as dspace/dspace-angular:$DSPACE_VERSION-dist
2+
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
3+
4+
# Test build:
5+
# docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-7_x-dist .
6+
7+
FROM node:18-alpine as build
8+
9+
# Ensure Python and other build tools are available
10+
# These are needed to install some node modules, especially on linux/arm64
11+
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
12+
13+
WORKDIR /app
14+
COPY package.json yarn.lock ./
15+
RUN yarn install --network-timeout 300000
16+
17+
ADD . /app/
18+
RUN yarn build:prod
19+
20+
FROM node:18-alpine
21+
RUN npm install --global pm2
22+
23+
COPY --chown=node:node --from=build /app/dist /app/dist
24+
COPY --chown=node:node config /app/config
25+
COPY --chown=node:node docker/dspace-ui.json /app/dspace-ui.json
26+
27+
WORKDIR /app
28+
USER node
29+
ENV NODE_ENV production
30+
EXPOSE 4000
31+
CMD pm2-runtime start dspace-ui.json --json

docker/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
If you wish to run DSpace on Docker in production, we recommend building your own Docker images. You are welcome to borrow ideas/concepts from the below images in doing so. But, the below images should not be used "as is" in any production scenario.
77
***
88

9-
## 'Dockerfile' in root directory
9+
## 'Dockerfile' in root directory
1010
This Dockerfile is used to build a *development* DSpace 7 Angular UI image, published as 'dspace/dspace-angular'
1111

1212
```
@@ -20,6 +20,15 @@ Admins to our DockerHub repo can manually publish with the following command.
2020
docker push dspace/dspace-angular:dspace-7_x
2121
```
2222

23+
The `Dockerfile.dist` is used to generate a *production* build and runtime environment.
24+
25+
```bash
26+
# build the latest image
27+
docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-7_x-dist .
28+
```
29+
30+
A default/demo version of this image is built *automatically*.
31+
2332
## docker directory
2433
- docker-compose.yml
2534
- Starts DSpace Angular with Docker Compose from the current branch. This file assumes that a DSpace 7 REST instance will also be started in Docker.
@@ -62,6 +71,14 @@ From DSpace/DSpace-angular
6271
docker-compose -p d7 -f docker/docker-compose.yml up -d
6372
```
6473

74+
## Run DSpace Angular dist build with DSpace Demo site backend
75+
76+
```
77+
docker-compose -f docker/docker-compose-dist.yml pull
78+
docker-compose -f docker/docker-compose-dist.yml build
79+
docker-compose -p d7 -f docker/docker-compose-dist.yml up -d
80+
```
81+
6582
## Ingest test data from AIPDIR
6683

6784
Create an administrator

docker/docker-compose-dist.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# The contents of this file are subject to the license and copyright
3+
# detailed in the LICENSE and NOTICE files at the root of the source
4+
# tree and available online at
5+
#
6+
# http://www.dspace.org/license/
7+
#
8+
9+
# Docker Compose for running the DSpace Angular UI dist build
10+
# for previewing with the DSpace Demo site backend
11+
version: '3.7'
12+
networks:
13+
dspacenet:
14+
services:
15+
dspace-angular:
16+
container_name: dspace-angular
17+
environment:
18+
DSPACE_UI_SSL: 'false'
19+
DSPACE_UI_HOST: dspace-angular
20+
DSPACE_UI_PORT: '4000'
21+
DSPACE_UI_NAMESPACE: /
22+
DSPACE_REST_SSL: 'true'
23+
DSPACE_REST_HOST: api7.dspace.org
24+
DSPACE_REST_PORT: 443
25+
DSPACE_REST_NAMESPACE: /server
26+
image: dspace/dspace-angular:dspace-7_x-dist
27+
build:
28+
context: ..
29+
dockerfile: Dockerfile.dist
30+
networks:
31+
dspacenet:
32+
ports:
33+
- published: 4000
34+
target: 4000
35+
stdin_open: true
36+
tty: true

docker/dspace-ui.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"apps": [
3+
{
4+
"name": "dspace-ui",
5+
"cwd": "/app",
6+
"script": "dist/server/main.js",
7+
"instances": "max",
8+
"exec_mode": "cluster"
9+
}
10+
]
11+
}

0 commit comments

Comments
 (0)