Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,23 @@ jobs:
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push
# https://github.com/docker/build-push-action/releases/tag/v6.7.0
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
# https://github.com/docker/build-push-action/releases/tag/v6.15.0
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push RabbitMQ image
# https://github.com/docker/build-push-action/releases/tag/v6.15.0
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
if: steps.tags.outputs.rabbitmq_tags != ''
with:
build-args:
ENABLE_RABBITMQ=true
push: true
tags: ${{ steps.tags.outputs.rabbitmq_tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG IMG=node:22.11-alpine3.19

FROM $IMG as builder
FROM $IMG AS builder

WORKDIR /usr/src/app/

Expand All @@ -17,7 +17,7 @@ COPY config.js.docker ./src/config.js

RUN npm run build && npm run build-scripts

FROM $IMG as deps
FROM $IMG AS deps

WORKDIR /usr/src/app/
ENV NODE_ENV=production
Expand All @@ -27,8 +27,14 @@ ENV NODE_ENV=production

COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .gyp python3 make g++ &&\
npm ci --only=production &&\
apk del .gyp &&\
npm ci --only=production

# Install amqp library if RabbitMQ is enabled
ARG ENABLE_RABBITMQ=false
ENV ENABLE_RABBITMQ=${ENABLE_RABBITMQ}
RUN if [ "$ENABLE_RABBITMQ" = "true" ]; then npm install amqplib@0.10.5; fi

RUN apk del .gyp &&\
npm cache clean --force &&\
rm -rf /tmp/* /var/cache/apk/*

Expand Down
12 changes: 10 additions & 2 deletions scripts/github/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def prep_tags(environ: Dict):
ref = environ.get('GITHUB_REF')
sha = environ.get('GITHUB_SHA')
tags = set()
# These are used to deploy images with the RabbitMQ plugin included
rabbitmq_tags = set()

if ref.startswith('refs/tags/'):
git_tag = ref[10:]
Expand All @@ -39,10 +41,14 @@ def prep_tags(environ: Dict):
tags.add(base_ecr_tag + version)
tags.add(base_ecr_tag + '{}-{}'.format(sha, timestamp))
tags.add(base_ecr_tag + 'latest')
rabbitmq_tags.add(base_ecr_tag + version + '-rabbitmq')
rabbitmq_tags.add(base_ecr_tag + 'latest-rabbitmq')

tags.add(base_dockerhub_tag + version)
tags.add(base_dockerhub_tag + '{}-{}'.format(sha, timestamp))
tags.add(base_dockerhub_tag + 'latest')
rabbitmq_tags.add(base_dockerhub_tag + version + '-rabbitmq')
rabbitmq_tags.add(base_dockerhub_tag + 'latest-rabbitmq')
elif ref == 'refs/heads/master':
# A push to master creates a staging tag
tags.add(base_ecr_tag + 'staging-{}-{}'.format(sha, timestamp))
Expand All @@ -53,14 +59,16 @@ def prep_tags(environ: Dict):
# XXX: We currently do not run on other branches
tags.add(base_ecr_tag + 'dev-{}-{}'.format(sha, timestamp))

return tags
return tags, rabbitmq_tags

def print_output(output: Dict):
outputs = ['{}={}\n'.format(k, v) for k, v in output.items()]
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.writelines(outputs)

if __name__ == '__main__':
tags = prep_tags(os.environ)
tags, rabbitmq_tags = prep_tags(os.environ)
if tags:
print_output({'tags': ','.join(tags)})
if rabbitmq_tags:
print_output({'rabbitmq_tags': ','.join(rabbitmq_tags)})
Loading