-
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.
Merge pull request #3 from ItsRaelx/main
Add Dockerfile and automatic docker building
- Loading branch information
Showing
7 changed files
with
532 additions
and
434 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,45 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Convert IMAGE_NAME to lowercase | ||
run: | | ||
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV | ||
- name: Build the Docker image | ||
run: | | ||
docker build . --file Dockerfile --tag $IMAGE_NAME:${{ github.sha }} | ||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Tag the image with the 'latest' tag | ||
run: | | ||
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:latest | ||
- name: Tag the image with the SHA | ||
run: | | ||
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:${{ github.sha }} | ||
- name: Push the Docker image to GitHub Container Registry | ||
run: | | ||
docker push ghcr.io/$IMAGE_NAME:latest | ||
docker push ghcr.io/$IMAGE_NAME:${{ github.sha }} |
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,21 @@ | ||
# Use an official Node.js runtime as a parent image | ||
FROM node:latest | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
|
||
# Copy the current directory contents into the container at /usr/src/app | ||
COPY . . | ||
|
||
# Install any needed packages specified in package.json | ||
RUN npm install | ||
|
||
# Make port 3000 available to the world outside this container | ||
EXPOSE 3000 | ||
|
||
# Define environment variable | ||
ENV NODE_ENV=production | ||
ENV PORT=3000 | ||
|
||
# Run npm start when the container launches | ||
CMD ["npm", "run", "docker"] |
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
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
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
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
Oops, something went wrong.