Skip to content

Commit

Permalink
fix: refactor backend
Browse files Browse the repository at this point in the history
  • Loading branch information
logicflakes committed May 18, 2024
1 parent 008e266 commit 96c45ac
Show file tree
Hide file tree
Showing 13 changed files with 800 additions and 651 deletions.
3 changes: 2 additions & 1 deletion backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
**/.git
get_version_command
get_version_exec
reliza_command
reliza_command
dist
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
44 changes: 32 additions & 12 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@
FROM node:18-alpine3.17 as builder
FROM node:20-alpine3.18 as builder

ARG CI_ENV=noci
ARG GIT_COMMIT=git_commit_undefined
ARG GIT_BRANCH=git_branch_undefined
ARG VERSION=not_versioned
ARG TARGETARCH
ARG TARGETOS
ARG CYCLONE_DX_CLI_VERSION=v0.25.0

RUN if [ "$TARGETARCH" = "amd64" ]; then \
wget https://github.com/CycloneDX/cyclonedx-cli/releases/download/${CYCLONE_DX_CLI_VERSION}/cyclonedx-linux-musl-x64 ;\
mv cyclonedx-linux-musl-x64 /usr/local/bin/cyclonedx-cli ;\
elif [ "$TARGETARCH" = "arm64" ]; then \
wget https://github.com/CycloneDX/cyclonedx-cli/releases/download/${CYCLONE_DX_CLI_VERSION}/cyclonedx-${TARGETOS}-${TARGETARCH} ;\
mv cyclonedx-${TARGETOS}-${TARGETARCH} /usr/local/bin/cyclonedx-cli ;\
fi

RUN mkdir /app
WORKDIR /app
COPY package*.json ./
RUN npm i
COPY ./ .
RUN npm run build

FROM node:20-alpine3.18 as package

ARG CI_ENV=noci
ARG GIT_COMMIT=git_commit_undefined
ARG GIT_BRANCH=git_branch_undefined
ARG VERSION=not_versioned

COPY --from=builder /usr/local/bin/cyclonedx-cli /usr/local/bin/

ENV \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8
RUN apk add --no-cache \
icu-data-full \
icu-libs
RUN mkdir /app
RUN echo "version=$VERSION" > /app/version && echo "commit=$GIT_COMMIT" >> /app/version && echo "branch=$GIT_BRANCH" >> /app/version
icu-libs && \
mkdir /app && echo "version=$VERSION" > /app/version && echo "commit=$GIT_COMMIT" >> /app/version && echo "branch=$GIT_BRANCH" >> /app/version

WORKDIR /app

RUN addgroup -S apprunner && adduser -S apprunner -G apprunner && chown apprunner:apprunner -R /app && chown apprunner:apprunner /usr/local/bin/cyclonedx-cli && chmod a+x /usr/local/bin/cyclonedx-cli
COPY package*.json ./
RUN npm install && npm install -g ts-node
COPY ./ .

COPY --chown=apprunner:apprunner package*.json ./
COPY --from=builder --chown=apprunner:apprunner /app/dist ./
COPY --chown=apprunner:apprunner migrations /app/migrations

USER apprunner

RUN npm ci --omit=dev

LABEL git_commit $GIT_COMMIT
LABEL git_branch $GIT_BRANCH
Expand All @@ -36,4 +56,4 @@ LABEL version $VERSION

EXPOSE 4000

CMD ["npm", "start"]
CMD ["node", "index.js"]
Loading

0 comments on commit 96c45ac

Please sign in to comment.