From 540e52fa78f8b7179d405a757be8c24260f3af03 Mon Sep 17 00:00:00 2001 From: LachlanCourt <80299053+LachlanCourt@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:54:12 +1100 Subject: [PATCH 1/7] Add dockerfile and build process (#1) * Add dockerfile and build process * Add actions workflows * Update workflow --- .dockerignore | 5 + .github/workflows/build-and-push-main.yml | 27 + .github/workflows/build-test.yml | 16 + Dockerfile | 15 + Makefile | 10 + index.html | 6 +- package-lock.json | 3425 --------------------- public/flag.svg | 21 + public/vite.svg | 1 - src/components/Flag/Flag.tsx | 1 + yarn.lock | 1582 ++++++++++ 11 files changed, 1680 insertions(+), 3429 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/build-and-push-main.yml create mode 100644 .github/workflows/build-test.yml create mode 100644 Dockerfile create mode 100644 Makefile delete mode 100644 package-lock.json create mode 100644 public/flag.svg delete mode 100644 public/vite.svg create mode 100644 yarn.lock diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..158e36e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +dist +node_modules +.gitignore +eslint.config.js +README.md diff --git a/.github/workflows/build-and-push-main.yml b/.github/workflows/build-and-push-main.yml new file mode 100644 index 0000000..9353f28 --- /dev/null +++ b/.github/workflows/build-and-push-main.yml @@ -0,0 +1,27 @@ +name: Build and Push + +on: + push: + branches: + - main + pull_request: + branches: + - main + - develop + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Build Docker Image + run: make build + - name: Login to GitHub Container Registry + run: echo ${{ secrets.REPOSITORY_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Get Repository name + run: echo USER_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + - name: Push Docker Image + run: | + docker tag flags ghcr.io/${{ env.USER_REPOSITORY }}:latest + docker push ghcr.io/${{ env.USER_REPOSITORY }}:latest diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..13b79a7 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,16 @@ +name: Build Test + +on: + pull_request: + branches: + - main + - develop + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Build Docker Image + run: make build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..718f947 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:20.19.5-alpine AS base + +COPY . ./code +WORKDIR /code + +# Build application +RUN yarn install +RUN yarn build + + +FROM nginx:stable-alpine + +COPY --from=base ./code/dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7bd7824 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +build-docker: + docker build -t flags:latest . +build: + make build-docker +prune: + docker container prune -f +start-app: + docker run -p 4000:80 --name flags flags:latest +run: + make prune && make start-app diff --git a/index.html b/index.html index b4a5a0b..ac217f7 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,10 @@ - +
- + -