forked from NOAA-OWP/ngencerf-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (64 loc) · 2.29 KB
/
Dockerfile
File metadata and controls
79 lines (64 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
FROM rockylinux:9.3
# runtime dependencies
RUN set -eux; \
dnf install -y dnf-plugins-core; \
dnf config-manager --set-enabled crb; \
dnf install -y --allowerasing \
file \
findutils \
git \
openssl openssl-devel \
which \
xz \
jq \
curl \
; \
dnf clean all; \
rm -rf /var/cache/dnf
# set node and npm versions
ARG NODE_VERSION=22.17.0
ARG NPM_VERSION=10.9.2
ARG NODE_TAR_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz"
# install node
RUN curl --fail --silent --show-error --location "$NODE_TAR_URL" | \
tar --extract --xz --directory=/usr/local --strip-components=1
# add node binaries to PATH
ENV PATH="/usr/local/bin:${PATH}"
# update npm version
RUN npm install -g npm@${NPM_VERSION} && npm cache clean --force
# create and set working directory
RUN mkdir --parents /var/www/ngencerf/nuxt-app
WORKDIR /var/www/ngencerf/nuxt-app
# install node dependencies
COPY package*.json ./
RUN set -eux; \
npm ci
COPY . .
RUN set -eux; \
npm run build
# Extract Git information and write it to a JSON file at $GIT_INFO_PATH
COPY .git .git
RUN set -eux; \
# Get the remote URL from Git configuration
repo_url=$(git config --get remote.origin.url); \
# Extract the repo name (everything after the last slash) and remove any trailing .git
key=${repo_url##*/}; \
key=${key%.git}; \
# Construct the file path using the derived key
GIT_INFO_PATH="${key}_git_info.json"; \
jq -n \
--arg commit_hash "$(git rev-parse HEAD)" \
--arg branch "$(git rev-parse --abbrev-ref HEAD)" \
--arg tags "$(git tag --points-at HEAD | tr '\n' ' ')" \
--arg author "$(git log -1 --pretty=format:'%an')" \
--arg commit_date "$(date -u -d @$(git log -1 --pretty=format:'%ct') +'%Y-%m-%d %H:%M:%S UTC')" \
--arg message "$(git log -1 --pretty=format:'%s' | tr '\n' ';')" \
--arg build_date "$(date -u +'%Y-%m-%d %H:%M:%S UTC')" \
"{\"$key\": {commit_hash: \$commit_hash, branch: \$branch, tags: \$tags, author: \$author, commit_date: \$commit_date, message: \$message, build_date: \$build_date}}" \
> $GIT_INFO_PATH
RUN rm --recursive --force .git
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
ENTRYPOINT [ "npm" ]
CMD [ "run", "start" ]
EXPOSE 3000