Skip to content

Commit

Permalink
feat: Update Dockerfile to retrieve and set git project version
Browse files Browse the repository at this point in the history
  • Loading branch information
Codycody31 committed Oct 13, 2023
1 parent 021601d commit c334f73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
FROM node:18.17 AS builder

# TODO: Get git project version and save to environment variable and file
# Set working directory
WORKDIR /app

# Copy the git project to the working directory
COPY .git/ .git/

# Get the git project version and set it as an environment variable
RUN VERSION=$(git describe --tags --always --dirty)
# Save git version to an environment variable
ARG GIT_VERSION=$(VERSION)

# Set working directory
WORKDIR /app/frontend

# Build the frontend
# Set the environment variable for the frontend
ENV VUE_APP_GIT_VERSION=$GIT_VERSION
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
Expand All @@ -17,6 +29,8 @@ WORKDIR /app/backend
COPY backend/package*.json ./
RUN npm install
COPY backend/ .
# Save the git version to a file for the backend
RUN echo $GIT_VERSION > ./version

# Use Apache to serve the frontend and proxy to the backend
FROM httpd:2.4
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ export default {
computed: {
gitTag() {
// If tag is a version number, return it
if (process.env.VUE_APP_GIT_TAG.match(/^v\d+\.\d+\.\d+$/)) {
if (process.env.VUE_APP_GIT_VERSION.match(/^v\d+\.\d+\.\d+$/)) {
return {
version: process.env.VUE_APP_GIT_TAG,
version: process.env.VUE_APP_GIT_VERSION,
type: "version",
};
} else {
return {
version: process.env.VUE_APP_GIT_COMMIT_HASH,
version: process.env.VUE_APP_GIT_VERSION,
type: "commit",
};
}
Expand Down

0 comments on commit c334f73

Please sign in to comment.