Skip to content

Commit 0287dd1

Browse files
authored
Merge pull request #1149 from iwisunny/feat/build-for-arm-platform
feat: Add ARM platform docker build
2 parents 41f57d4 + 679a4a0 commit 0287dd1

File tree

6 files changed

+5123
-5355
lines changed

6 files changed

+5123
-5355
lines changed

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
package-lock=false
21
scripts-prepend-node-path=true
2+
registry=https://registry.npm.taobao.org
3+
sass-binary-site=https://npm.taobao.org/mirrors/node-sass

Dockerfile.arm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM node:12-alpine as builder
2+
MAINTAINER sunnyw <sunnywang@yunify.com>
3+
4+
ENV SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass
5+
ENV PATH=$PATH:/home/node_modules/.bin
6+
7+
WORKDIR /home/app
8+
9+
RUN mkdir -p /home/app
10+
11+
RUN npm config set registry https://registry.npm.taobao.org
12+
13+
COPY package.json yarn.lock /tmp/
14+
15+
# generate dev node modules and prod node modules
16+
RUN cd /tmp && mkdir -p node_modules \
17+
&& yarn install --pure-lockfile --prefer-offline \
18+
&& mv node_modules dev_node_modules \
19+
&& NODE_ENV=production yarn install --pure-lockfile --prod --prefer-offline \
20+
&& mv node_modules prod_node_modules \
21+
&& mv dev_node_modules node_modules
22+
23+
COPY . /home/app
24+
25+
RUN cd /home/app && \
26+
ln -fs /tmp/node_modules && \
27+
yarn prod:build
28+
29+
30+
FROM yobasystems/alpine-nodejs:min-aarch64
31+
32+
ENV NODE_ENV=production
33+
34+
WORKDIR /home/app
35+
36+
RUN mkdir -p /home/app
37+
38+
COPY --from=builder /home/app /home/app
39+
COPY --from=builder /tmp/prod_node_modules /home/app/node_modules
40+
41+
EXPOSE 8000
42+
43+
CMD ["npm", "run", "prod:serve"]

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ docker-tag:
4949
docker build --cache-from ${repo}:latest -t ${repo}:${tag} .
5050
docker push ${repo}:${tag}
5151

52+
build-arm: Dockerfile.arm
53+
@echo building image for ARM platform
54+
docker build -f Dockerfile.arm -t op/web-app-arm .
55+
56+
run-arm:
57+
@echo up and running openpitrix-dashboard in ARM platform
58+
docker run -p 8000:8000 --rm \
59+
--name openpitrix-dashboard-arm \
60+
-v "$(cwd)"/server/local_config.yml:/home/app/server/local_config.yml op/web-app-arm

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,50 @@
1414
```
1515
git clone https://github.com/openpitrix/dashboard.git
1616
cd dashboard
17-
yarn
17+
yarn
1818
yarn dev
1919
```
2020

21-
Or you can running dashboard in `docker`:
21+
## Docker
22+
23+
You can run dashboard in `docker`:
2224

2325
```
2426
docker pull openpitrix/dashboard
25-
docker run -d --name openpitrix-dashborad -p 8000:8000 openpitrix/dashboard
27+
docker run -d --rm --name openpitrix-dashborad -p 8000:8000 openpitrix/dashboard
28+
```
29+
30+
Then open your favorite browser: `http://localhost:8000`
31+
32+
## Build for ARM platform
33+
34+
We also support running `openpitrix/dashboard` in ARM platform using docker
35+
36+
See build steps in `Dockerfile.arm`
37+
38+
If you want try local build for ARM:
39+
40+
```
41+
make build-arm
42+
make run-arm
43+
```
44+
45+
Or running our official arm64 image from docker hub:
46+
47+
```
48+
docker pull openpitrix/dashboard:min-arm64
49+
docker run -d --rm --name openpitrix-dashborad-arm -p 8000:8000 openpitrix/dashboard:min-arm64
2650
```
27-
Then open your browser: `http://localhost:8000`
2851

2952
## Develop
53+
3054
```
31-
yarn
55+
yarn
3256
yarn dev
3357
```
3458

3559
We prefer `yarn` as our package manager, if you like `npm`:
60+
3661
```
3762
npm i
3863
npm run dev
@@ -41,26 +66,22 @@ npm run dev
4166
See [How to install requsites](./docs/install.md)
4267

4368
## Test
69+
4470
```
4571
yarn test
4672
```
4773

4874
## Build
4975

5076
For production build:
77+
5178
```
5279
yarn prod:build
5380
```
54-
Or using `npm`:
55-
```
56-
npm run prod:build
57-
```
58-
5981

6082
## Quick start
6183

62-
* [Deploy wordpress on QingCloud using openpitrix](./docs/quick-start.md)
63-
84+
- [Deploy wordpress on QingCloud using openpitrix](./docs/quick-start.md)
6485

6586
## License
6687

deploy-docker.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -ex
44

55
REPO=openpitrix/dashboard
66
COMMIT=$(git rev-parse --short HEAD)
7+
TAG=${1:-latest}
78

8-
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
9+
cat ~/docker_pass.txt | docker login --username iwisunny --password-stdin
910

1011
echo "Pulling remote latest image to reuse docker cache"
1112
docker pull $REPO:latest
@@ -14,7 +15,7 @@ echo "Building docker image from git HEAD commit: $COMMIT"
1415
docker build --cache-from $REPO:latest -t $REPO:$COMMIT .
1516

1617
echo "Tag $REPO:$COMMIT as latest image"
17-
docker tag $REPO:$COMMIT $REPO:latest
18+
docker tag $REPO:$COMMIT $REPO:$TAG
1819

1920
echo "Push latest image to docker hub"
20-
docker push $REPO:latest
21+
docker push $REPO:$TAG

0 commit comments

Comments
 (0)