Skip to content

Commit

Permalink
chore(ci): implementing Dockerfile and Github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Aazme committed Mar 18, 2024
1 parent 9b70cad commit 700c159
Show file tree
Hide file tree
Showing 3 changed files with 3,441 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/Docker Image Build & Push To Registery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker Image Build & Push To Registery

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin ${{ secrets.DOCKER_REGISTRY }}

- name: Set image tag
id: tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/heads/}

- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_REGISTRY }}/coworking-space-api:${{ steps.tag.outputs.TAG }} .
docker push ${{ secrets.DOCKER_REGISTRY }}/coworking-space-api:${{ steps.tag.outputs.TAG }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependency installation stage
FROM node:20-alpine AS dependencies

WORKDIR /usr/src/app

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

# Install dependencies
RUN npm install

# Production stage
FROM node:20-alpine AS production

WORKDIR /usr/src/app

# Copy only production dependencies from the dependencies stage
COPY --from=dependencies /usr/src/app/node_modules ./node_modules

# Copy the rest of the application code
COPY . .

# Expose the port the app runs on
EXPOSE 3000

# Command to run the application
CMD ["node", "index.js"]
Loading

0 comments on commit 700c159

Please sign in to comment.