Skip to content

Commit

Permalink
added pr build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-afegbua committed Jan 9, 2024
1 parent c78d4ba commit eb57bc2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pr-docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build Docker Image on PR to ref main branch

on:
pull_request:
branches:
- 'master'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout out the repo
uses: actions/checkout@v2

- name: Log into the Container registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set Docker tag as short commit sha
id: tag
run: echo "::set-output name=TAG::$(echo $GITHUB_SHA | head -c 8)"

- name: Build and push the Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO }}:${{ steps.tag.outputs.TAG }}
File renamed without changes.
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# syntax = docker/dockerfile:1.3

# Always add commit hash for reproducability
# Always add commit hash for reproducibility
FROM node:18-alpine@sha256:3482a20c97e401b56ac50ba8920cc7b5b2022bfc6aa7d4e4c231755770cf892f

# Enable prod optimizations
ENV NODE_ENV=production
ENV NODE_ENV=production \
NPM_CONFIG_PRODUCTION=false

WORKDIR /app
RUN apk add --update --no-cache g++ make python3 && \
ln -sf python3 /usr/bin/python && \
apk add --update --no-cache yarn

# Install build dependencies and clean up
RUN apk add --update --no-cache \
g++ \
make \
python3 \
&& ln -sf python3 /usr/bin/python \
&& apk add --update --no-cache yarn \
&& apk add --no-cache tini \
&& rm -rf /var/cache/apk/*

# Copy package.json and yarn.lock for optimised caching
COPY ["package.json", "yarn.lock", "./"]
RUN yarn install --frozen-lockfile --production
COPY . /app

# make sure we can write the data directory
RUN chown node:node data
# Make sure we can write the data directory
RUN mkdir -p data

# Install application dependencies
RUN yarn install --frozen-lockfile --production

# Add a simple init system so that Node would respect process signals
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]

# Don't run as root
USER node
CMD ["node", "main.js" ]
CMD ["node", "main.js"]

0 comments on commit eb57bc2

Please sign in to comment.