Skip to content

Commit

Permalink
build: publish docker images for dl-queue
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianNoise committed May 24, 2024
1 parent 58b4df7 commit 7c95118
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publish-dl-queue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish dl-queue

on:
push:
branches:
- main
paths:
- 'dl-queue/**'
workflow_dispatch:

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./dl-queue/
push: true
tags: |
ghcr.io/${{ env.OWNER_LC }}/dl-queue:${{ github.sha }}
ghcr.io/${{ env.OWNER_LC }}/dl-queue:latest
3 changes: 3 additions & 0 deletions dl-queue/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env*
node_modules/
test/
43 changes: 43 additions & 0 deletions dl-queue/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use an official Node.js runtime as the base image for the build stage
FROM node:14 as build

# Set the working directory in the Docker image
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install the project dependencies
RUN npm install

# Copy the rest of the project files to the working directory
COPY . .

# Compile the TypeScript code
RUN npm run build

# Start a new stage for the production image
FROM node:14-alpine

LABEL org.opencontainers.image.source https://github.com/BelgianNoise/dl-utils

# Set the working directory
WORKDIR /usr/src/app

# Copy only the built application and the necessary production dependencies from the build stage
COPY --from=build /usr/src/app/dist ./dist
COPY --from=build /usr/src/app/node_modules ./node_modules

ENV POSTGRES_USERNAME=
ENV POSTGRES_PASSWORD=
ENV POSTGRES_HOST=
ENV POSTGRES_PORT=
ENV POSTGRES_DATABASE=

ENV AUTH_SECRET=

# Expose port 3000 for the application
EXPOSE 3000

# Start the application
CMD [ "node", "dist/index.js" ]

0 comments on commit 7c95118

Please sign in to comment.