-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Added dockerfile * feat: Now publishing dockerfile in github action
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Node modules | ||
node_modules | ||
|
||
# Logs | ||
npm-debug.log | ||
logs | ||
|
||
# Build output | ||
dist | ||
|
||
# Version control | ||
.git | ||
.gitignore | ||
|
||
# Environment variables | ||
.env | ||
|
||
# IDE files | ||
.vscode | ||
.idea | ||
|
||
# OS files | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Docker Publish | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
release: | ||
types: [created] | ||
|
||
env: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/hxckr-webhook-handler | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
install: true | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ env.DOCKERHUB_USERNAME }} | ||
password: ${{ env.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
${{ env.IMAGE_NAME }}:latest | ||
${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache | ||
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Use an official Node.js runtime as the base image | ||
FROM node:18-alpine | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json (or yarn.lock) | ||
COPY package*.json ./ | ||
|
||
# Install all dependencies (including devDependencies for building) | ||
RUN npm install | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Build the TypeScript code | ||
RUN npx tsc | ||
|
||
# Remove devDependencies | ||
RUN npm prune --production | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
|
||
# Set NODE_ENV to production | ||
ENV NODE_ENV=production | ||
|
||
# Run the application | ||
CMD ["node", "dist/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters