Skip to content

Commit

Permalink
ci: add build step in docker (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored Jul 24, 2024
1 parent 18f047c commit 7fe000b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'npm'
- name: Install Dependencies
run: npm install

- name: Build
run: |
VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/"version"://g' | sed 's/[",]//g' | tr -d '[[:space:]]')
CI_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD)
echo "{\"commit\": \"$CI_COMMIT_SHORT_SHA\", \"version\": \"$VERSION\"}" > src/data/version.json
npm run build
- name: Check correct tag and version
run: |
VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/"version"://g' | sed 's/[",]//g' | tr -d '[[:space:]]')
Expand Down
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
FROM nginx:1.25.1
FROM node:20 AS build

WORKDIR /app
COPY package.json package-lock.json ./
COPY src src
COPY public public
COPY build build
RUN npm install
RUN VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/"version"://g' | sed 's/[",]//g' | tr -d '[[:space:]]') CI_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD) echo "{\"commit\": \"$CI_COMMIT_SHORT_SHA\", \"version\": \"$VERSION\"}" > src/data/version.json
RUN npm run build


FROM nginx:1.25.1

WORKDIR /app
COPY --from=build build build

# Configure the nginx inside the docker image
COPY .templates/nginx.conf /etc/nginx/conf.d/
Expand Down

0 comments on commit 7fe000b

Please sign in to comment.