Skip to content

Commit 02a7e08

Browse files
authored
Merge pull request #5 from ohdoking/ss_mny6x3
[🤖 Infrapal Bot]Add Dockerfile, GitHub workflow, and Docker Compose
2 parents 785e0f8 + d237ecd commit 02a7e08

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy to GitHub Container Registry
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
packages: write # Required to push to GitHub Container Registry
15+
16+
steps:
17+
# Checkout the code
18+
- name: Checkout Code
19+
uses: actions/checkout@v3
20+
21+
# Authenticate to GitHub Container Registry
22+
- name: Log in to GitHub Container Registry
23+
run: |
24+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
25+
26+
# Build and tag the Docker image
27+
- name: Build and Tag Docker Image
28+
run: |
29+
docker build -t node-javascript-mysql-demo .
30+
docker tag node-javascript-mysql-demo:latest ghcr.io/${{ github.repository_owner }}/node-javascript-mysql-demo:latest
31+
32+
# Push the Docker image to GHCR
33+
- name: Push Docker Image to GitHub Container Registry
34+
run: |
35+
docker push ghcr.io/${{ github.repository_owner }}/node-javascript-mysql-demo:latest

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use the official lightweight Node.js image
2+
FROM node:14-alpine
3+
4+
# Set the working directory
5+
WORKDIR /usr/src/app
6+
7+
# Copy project files
8+
COPY . .
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Expose the application port
14+
EXPOSE 3000
15+
16+
# Set the entry point
17+
CMD ["node", "index.js"]

docker-compose.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
environment:
9+
- DB_HOST=mysql
10+
- DB_USER=root
11+
- DB_PASSWORD=password
12+
- DB_NAME=word_database
13+
- PORT=3000
14+
ports:
15+
- "3000:3000"
16+
depends_on:
17+
- mysql
18+
19+
mysql:
20+
image: mysql:latest
21+
restart: always
22+
environment:
23+
MYSQL_ROOT_PASSWORD: password
24+
MYSQL_DATABASE: word_database
25+
MYSQL_USER: root
26+
MYSQL_PASSWORD: password
27+
ports:
28+
- "3306:3306"
29+
volumes:
30+
- mysql_data:/var/lib/mysql
31+
32+
volumes:
33+
mysql_data:

0 commit comments

Comments
 (0)