Skip to content

Commit fbe10e7

Browse files
geekgonecrazyLuluGOggazzorodrigoksampaiodiego
authored
Add: Alpine image as option for build (#12548)
* Switch to alpine base * Rename to Dockerfile.alpine * changing image to avoid segfault when installing sharp, and update sharp and grpc version according to packages.json * Update node version * grpc hack seems no longer needed * Apply suggestions from code review Co-authored-by: Diego Sampaio <[email protected]> * Update base image * Build alpine on CI * add --production Co-authored-by: Debdut Chakraborty <[email protected]> Co-authored-by: LuluGO <[email protected]> Co-authored-by: Guilherme Gazzo <[email protected]> Co-authored-by: Rodrigo Nascimento <[email protected]> Co-authored-by: Diego Sampaio <[email protected]> Co-authored-by: Debdut Chakraborty <[email protected]>
1 parent 3e14178 commit fbe10e7

File tree

2 files changed

+72
-14
lines changed

2 files changed

+72
-14
lines changed

.docker/Dockerfile.alpine

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:14.18.3-alpine3.15
2+
3+
RUN apk add --no-cache python3 make g++ libc6-compat ttf-dejavu
4+
5+
ADD . /app
6+
7+
8+
9+
RUN set -x \
10+
&& cd /app/bundle/programs/server \
11+
&& npm install --production \
12+
# Start hack for sharp...
13+
&& rm -rf npm/node_modules/sharp \
14+
&& npm install [email protected] \
15+
&& mv node_modules/sharp npm/node_modules/sharp \
16+
# End hack for sharp
17+
&& cd npm \
18+
&& npm rebuild bcrypt --build-from-source \
19+
&& npm cache clear --force
20+
21+
# needs a mongo instance - defaults to container linking with alias 'mongo'
22+
ENV DEPLOY_METHOD=docker \
23+
NODE_ENV=production \
24+
MONGO_URL=mongodb://mongo:27017/rocketchat \
25+
HOME=/tmp \
26+
PORT=3000 \
27+
ROOT_URL=http://localhost:3000 \
28+
Accounts_AvatarStorePath=/app/uploads
29+
30+
VOLUME /app/uploads
31+
32+
WORKDIR /app/bundle
33+
34+
EXPOSE 3000
35+
36+
CMD ["node", "main.js"]

.github/workflows/build_and_test.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,11 @@ jobs:
488488

489489
strategy:
490490
matrix:
491-
release: ["official", "preview"]
491+
# this is current a mix of variants and different images
492+
release: ["official", "preview", "alpine"]
492493

493494
env:
494-
IMAGE: "rocketchat/rocket.chat"
495+
IMAGE_NAME: "rocketchat/rocket.chat"
495496

496497
steps:
497498
- uses: actions/checkout@v2
@@ -508,7 +509,7 @@ jobs:
508509
name: build
509510
path: /tmp/build
510511

511-
- name: Unpack build
512+
- name: Unpack build and prepare Docker files
512513
run: |
513514
cd /tmp/build
514515
tar xzf Rocket.Chat.tar.gz
@@ -519,8 +520,13 @@ jobs:
519520
DOCKER_PATH="${DOCKER_PATH}-mongo"
520521
fi;
521522
522-
echo "Build ${{ matrix.release }} Docker image"
523-
cp ${DOCKER_PATH}/Dockerfile .
523+
DOCKERFILE_PATH="${DOCKER_PATH}/Dockerfile"
524+
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
525+
DOCKERFILE_PATH="${DOCKERFILE_PATH}.${{ matrix.release }}"
526+
fi;
527+
528+
echo "Copy Dockerfile for release: ${{ matrix.release }}"
529+
cp $DOCKERFILE_PATH ./Dockerfile
524530
if [ -e ${DOCKER_PATH}/entrypoint.sh ]; then
525531
cp ${DOCKER_PATH}/entrypoint.sh .
526532
fi;
@@ -529,35 +535,51 @@ jobs:
529535
if: github.event_name == 'release'
530536
run: |
531537
cd /tmp/build
532-
GIT_TAG="${GITHUB_REF#*tags/}"
538+
539+
DOCKER_TAG="${GITHUB_REF#*tags/}"
533540
534541
if [[ '${{ matrix.release }}' = 'preview' ]]; then
535-
IMAGE="${IMAGE}.preview"
542+
IMAGE_NAME="${IMAGE_NAME}.preview"
536543
fi;
537544
538-
docker build -t ${IMAGE}:$GIT_TAG .
539-
docker push ${IMAGE}:$GIT_TAG
545+
# append the variant name to docker tag
546+
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
547+
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
548+
fi;
549+
550+
docker build -t $IMAGE_NAME:$DOCKER_TAG .
551+
docker push $IMAGE_NAME:$DOCKER_TAG
540552
541553
if echo "$GIT_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then
542554
RELEASE="latest"
543555
elif echo "$GIT_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$' ; then
544556
RELEASE="release-candidate"
545557
fi
546558
547-
docker tag ${IMAGE}:$GIT_TAG ${IMAGE}:${RELEASE}
548-
docker push ${IMAGE}:${RELEASE}
559+
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
560+
RELEASE="${RELEASE}-${{ matrix.release }}"
561+
fi;
562+
563+
docker tag $IMAGE_NAME:$DOCKER_TAG $IMAGE_NAME:$RELEASE
564+
docker push $IMAGE_NAME:$RELEASE
549565
550566
- name: Build Docker image for develop
551567
if: github.ref == 'refs/heads/develop'
552568
run: |
553569
cd /tmp/build
554570
571+
DOCKER_TAG=develop
572+
555573
if [[ '${{ matrix.release }}' = 'preview' ]]; then
556-
IMAGE="${IMAGE}.preview"
574+
IMAGE_NAME="${IMAGE_NAME}.preview"
575+
fi;
576+
577+
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
578+
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
557579
fi;
558580
559-
docker build -t ${IMAGE}:develop .
560-
docker push ${IMAGE}:develop
581+
docker build -t $IMAGE_NAME:$DOCKER_TAG .
582+
docker push $IMAGE_NAME:$DOCKER_TAG
561583
562584
services-image-build:
563585
runs-on: ubuntu-20.04

0 commit comments

Comments
 (0)