Skip to content

Commit

Permalink
feat: github actions to build and pushes an image to the package repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Clue355 committed Dec 1, 2023
1 parent 0844cd0 commit 2406b91
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/[email protected]

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

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile.dev
push: true
tags: ghcr.io/clue355/github_dev:dev
45 changes: 45 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Specifies Node Version 18.18.2 & Alpine Linux Version 3.18 OS
FROM node:18.18.2-alpine3.18

# Application Container Root Directory
WORKDIR /app

# install pnpm globally inside container only
RUN npm install -g pnpm

# Copy dependency version files first to utilize dockers layer dependency caching
COPY package.json pnpm-lock.yaml ./

# install dependencies
RUN pnpm install

# Copy everything from the current DIR to the container DIR
COPY . .

# Starts the project
CMD ["pnpm", "run", "dev"]

# Specifies the port the container listens to
EXPOSE 3000

## build docker file and run in dev mode

# docker build -f Dockerfile.dev -t your-image-name .
# docker run --name container_name -p 3000:3000 -v $(pwd):/app image_name

# Follow the real time logs again after stopping and starting the container
# docker logs -f container_name

# project link: http://localhost:3000/

# or

## build docker file and run in production mode

# docker build -f Dockerfile.prod -t your-image-name .
# docker run --name container_name -p 3000:3000 your-image-name

# Follow the real time logs again after stopping and starting the container
# docker logs -f container_name

# project link: http://localhost:3000/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ docker compose down app-dev

`Note: After running docker compose down the image you pulled will still exist on your local computer`

For production you just replace app-dev with app-prod
`Note: For production you just replace app-dev with app-prod`

## Useful Docker commands

Expand Down

0 comments on commit 2406b91

Please sign in to comment.