Skip to content

Commit

Permalink
Multi-arch dockerfile and release (#5)
Browse files Browse the repository at this point in the history
* Multi-arch dockerfile and release

* Bumped package version and upgrades insecure dep
  • Loading branch information
dblane-digicatapult authored Aug 8, 2022
1 parent f0844db commit 9142e2a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1,262 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check token
- name: Check Github token
run: |
if [ -z "${{ secrets.GITHUB_TOKEN }}"]; then
echo "Must provide a GITHUB_TOKEN secret in order to run release workflow"
exit 1
fi
- name: Check Dockerhubtoken
run: |
if [ -z "${{ secrets.DSBD_DOCKERHUB_TOKEN }}"]; then
echo "Must provide a DSBD_DOCKERHUB_TOKEN secret in order to run release workflow"
exit 1
fi
- name: Get repository identifiers
id: repo_ids
run: |
Expand Down Expand Up @@ -151,6 +157,11 @@ jobs:
registry: ghcr.io
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DSBD_DOOCKERHUB_USERNAME }}
password: ${{ secrets.DSBD_DOOCKERHUB_TOKEN }}
- name: Publish multi-arch image
uses: docker/build-push-action@v2
with:
Expand All @@ -162,6 +173,8 @@ jobs:
tags: |
ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ needs.check-version.outputs.version }}
ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest
${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ needs.check-version.outputs.version }}
${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest
labels: |
org.opencontainers.image.title=${{ needs.preconditions.outputs.repo_name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
Expand Down Expand Up @@ -199,4 +212,4 @@ jobs:
tag_name: latest
prerelease: false
name: Latest ${{ needs.check-version.outputs.version }}
generate_release_notes: true
generate_release_notes: true
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ RUN npm install
COPY . .
RUN npm run build

#Pull Assets
FROM node:16-alpine as assets

RUN apk --no-cache add curl
WORKDIR /tmp/
ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then export ARCHITECTURE=amd64; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then export ARCHITECTURE=arm64; else export ARCHITECTURE=amd64; fi \
&& curl -L https://github.com/gruntwork-io/fetch/releases/download/v0.4.5/fetch_linux_${ARCHITECTURE} --output ./fetch && chmod +x ./fetch
ARG MORELLO_EXAMPLES_VERSION=latest
ARG MORELLO_EXAMPLES_REPO=https://github.com/digicatapult/morello-examples

RUN ./fetch --repo="${MORELLO_EXAMPLES_REPO}" --tag="${MORELLO_EXAMPLES_VERSION}" --release-asset="morello-examples.tar.gz" ./ \
&& mkdir /morello-examples \
&& tar -xzf ./morello-examples.tar.gz -C /morello-examples

# Service
FROM node:16-alpine as service

Expand All @@ -24,6 +39,7 @@ COPY package*.json ./
RUN npm install --production
COPY --from=builder /morello-api/build .
COPY --from=builder /morello-api/config ./config
COPY --from=assets /morello-examples /morello-examples

EXPOSE 80
CMD [ "node", "./index.js" ]
Loading

0 comments on commit 9142e2a

Please sign in to comment.