-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2671 from Infisical/daniel/hsm
feat: hardware security module's support
- Loading branch information
Showing
36 changed files
with
1,467 additions
and
111 deletions.
There are no files selected for viewing
169 changes: 111 additions & 58 deletions
169
.github/workflows/release-standalone-docker-img-postgres-offical.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,115 @@ | ||
name: Release standalone docker image | ||
on: | ||
push: | ||
tags: | ||
- "infisical/v*.*.*-postgres" | ||
push: | ||
tags: | ||
- "infisical/v*.*.*-postgres" | ||
|
||
jobs: | ||
infisical-tests: | ||
name: Run tests before deployment | ||
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#overview | ||
uses: ./.github/workflows/run-backend-tests.yml | ||
infisical-standalone: | ||
name: Build infisical standalone image postgres | ||
runs-on: ubuntu-latest | ||
needs: [infisical-tests] | ||
steps: | ||
- name: Extract version from tag | ||
id: extract_version | ||
run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical/}" | ||
- name: ☁️ Checkout source | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 📦 Install dependencies to test all dependencies | ||
run: npm ci --only-production | ||
working-directory: backend | ||
- name: version output | ||
run: | | ||
echo "Output Value: ${{ steps.version.outputs.major }}" | ||
echo "Output Value: ${{ steps.version.outputs.minor }}" | ||
echo "Output Value: ${{ steps.version.outputs.patch }}" | ||
echo "Output Value: ${{ steps.version.outputs.version }}" | ||
echo "Output Value: ${{ steps.version.outputs.version_type }}" | ||
echo "Output Value: ${{ steps.version.outputs.increment }}" | ||
- name: Save commit hashes for tag | ||
id: commit | ||
uses: pr-mpt/actions-commit-hash@v2 | ||
- name: 🔧 Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: 🐋 Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set up Depot CLI | ||
uses: depot/setup-action@v1 | ||
- name: 📦 Build backend and export to Docker | ||
uses: depot/build-push-action@v1 | ||
with: | ||
project: 64mmf0n610 | ||
token: ${{ secrets.DEPOT_PROJECT_TOKEN }} | ||
push: true | ||
context: . | ||
tags: | | ||
infisical/infisical:latest-postgres | ||
infisical/infisical:${{ steps.commit.outputs.short }} | ||
infisical/infisical:${{ steps.extract_version.outputs.version }} | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile.standalone-infisical | ||
build-args: | | ||
POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} | ||
INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} | ||
infisical-tests: | ||
name: Run tests before deployment | ||
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#overview | ||
uses: ./.github/workflows/run-backend-tests.yml | ||
|
||
infisical-standalone: | ||
name: Build infisical standalone image postgres | ||
runs-on: ubuntu-latest | ||
needs: [infisical-tests] | ||
steps: | ||
- name: Extract version from tag | ||
id: extract_version | ||
run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical/}" | ||
- name: ☁️ Checkout source | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 📦 Install dependencies to test all dependencies | ||
run: npm ci --only-production | ||
working-directory: backend | ||
- name: version output | ||
run: | | ||
echo "Output Value: ${{ steps.version.outputs.major }}" | ||
echo "Output Value: ${{ steps.version.outputs.minor }}" | ||
echo "Output Value: ${{ steps.version.outputs.patch }}" | ||
echo "Output Value: ${{ steps.version.outputs.version }}" | ||
echo "Output Value: ${{ steps.version.outputs.version_type }}" | ||
echo "Output Value: ${{ steps.version.outputs.increment }}" | ||
- name: Save commit hashes for tag | ||
id: commit | ||
uses: pr-mpt/actions-commit-hash@v2 | ||
- name: 🔧 Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: 🐋 Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set up Depot CLI | ||
uses: depot/setup-action@v1 | ||
- name: 📦 Build backend and export to Docker | ||
uses: depot/build-push-action@v1 | ||
with: | ||
project: 64mmf0n610 | ||
token: ${{ secrets.DEPOT_PROJECT_TOKEN }} | ||
push: true | ||
context: . | ||
tags: | | ||
infisical/infisical:latest-postgres | ||
infisical/infisical:${{ steps.commit.outputs.short }} | ||
infisical/infisical:${{ steps.extract_version.outputs.version }} | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile.standalone-infisical | ||
build-args: | | ||
POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} | ||
INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} | ||
infisical-fips-standalone: | ||
name: Build infisical standalone image postgres | ||
runs-on: ubuntu-latest | ||
needs: [infisical-tests] | ||
steps: | ||
- name: Extract version from tag | ||
id: extract_version | ||
run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical/}" | ||
- name: ☁️ Checkout source | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 📦 Install dependencies to test all dependencies | ||
run: npm ci --only-production | ||
working-directory: backend | ||
- name: version output | ||
run: | | ||
echo "Output Value: ${{ steps.version.outputs.major }}" | ||
echo "Output Value: ${{ steps.version.outputs.minor }}" | ||
echo "Output Value: ${{ steps.version.outputs.patch }}" | ||
echo "Output Value: ${{ steps.version.outputs.version }}" | ||
echo "Output Value: ${{ steps.version.outputs.version_type }}" | ||
echo "Output Value: ${{ steps.version.outputs.increment }}" | ||
- name: Save commit hashes for tag | ||
id: commit | ||
uses: pr-mpt/actions-commit-hash@v2 | ||
- name: 🔧 Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: 🐋 Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set up Depot CLI | ||
uses: depot/setup-action@v1 | ||
- name: 📦 Build backend and export to Docker | ||
uses: depot/build-push-action@v1 | ||
with: | ||
project: 64mmf0n610 | ||
token: ${{ secrets.DEPOT_PROJECT_TOKEN }} | ||
push: true | ||
context: . | ||
tags: | | ||
infisical/infisical-fips:latest-postgres | ||
infisical/infisical-fips:${{ steps.commit.outputs.short }} | ||
infisical/infisical-fips:${{ steps.extract_version.outputs.version }} | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile.fips.standalone-infisical | ||
build-args: | | ||
POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} | ||
INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
ARG POSTHOG_HOST=https://app.posthog.com | ||
ARG POSTHOG_API_KEY=posthog-api-key | ||
ARG INTERCOM_ID=intercom-id | ||
ARG CAPTCHA_SITE_KEY=captcha-site-key | ||
|
||
FROM node:20-slim AS base | ||
|
||
FROM base AS frontend-dependencies | ||
WORKDIR /app | ||
|
||
COPY frontend/package.json frontend/package-lock.json frontend/next.config.js ./ | ||
|
||
# Install dependencies | ||
RUN npm ci --only-production --ignore-scripts | ||
|
||
# Rebuild the source code only when needed | ||
FROM base AS frontend-builder | ||
WORKDIR /app | ||
|
||
# Copy dependencies | ||
COPY --from=frontend-dependencies /app/node_modules ./node_modules | ||
# Copy all files | ||
COPY /frontend . | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_PUBLIC_ENV production | ||
ARG POSTHOG_HOST | ||
ENV NEXT_PUBLIC_POSTHOG_HOST $POSTHOG_HOST | ||
ARG POSTHOG_API_KEY | ||
ENV NEXT_PUBLIC_POSTHOG_API_KEY $POSTHOG_API_KEY | ||
ARG INTERCOM_ID | ||
ENV NEXT_PUBLIC_INTERCOM_ID $INTERCOM_ID | ||
ARG INFISICAL_PLATFORM_VERSION | ||
ENV NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION | ||
ARG CAPTCHA_SITE_KEY | ||
ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY $CAPTCHA_SITE_KEY | ||
|
||
# Build | ||
RUN npm run build | ||
|
||
# Production image | ||
FROM base AS frontend-runner | ||
WORKDIR /app | ||
|
||
RUN groupadd -r -g 1001 nodejs && useradd -r -u 1001 -g nodejs non-root-user | ||
|
||
RUN mkdir -p /app/.next/cache/images && chown non-root-user:nodejs /app/.next/cache/images | ||
VOLUME /app/.next/cache/images | ||
|
||
COPY --chown=non-root-user:nodejs --chmod=555 frontend/scripts ./scripts | ||
COPY --from=frontend-builder /app/public ./public | ||
RUN chown non-root-user:nodejs ./public/data | ||
|
||
COPY --from=frontend-builder --chown=non-root-user:nodejs /app/.next/standalone ./ | ||
COPY --from=frontend-builder --chown=non-root-user:nodejs /app/.next/static ./.next/static | ||
|
||
USER non-root-user | ||
|
||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
## | ||
## BACKEND | ||
## | ||
FROM base AS backend-build | ||
|
||
ENV ChrystokiConfigurationPath=/usr/safenet/lunaclient/ | ||
|
||
RUN groupadd -r -g 1001 nodejs && useradd -r -u 1001 -g nodejs non-root-user | ||
|
||
WORKDIR /app | ||
|
||
# Required for pkcs11js | ||
RUN apt-get update && apt-get install -y \ | ||
python3 \ | ||
make \ | ||
g++ \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY backend/package*.json ./ | ||
RUN npm ci --only-production | ||
|
||
COPY /backend . | ||
COPY --chown=non-root-user:nodejs standalone-entrypoint.sh standalone-entrypoint.sh | ||
RUN npm i -D tsconfig-paths | ||
RUN npm run build | ||
|
||
# Production stage | ||
FROM base AS backend-runner | ||
|
||
ENV ChrystokiConfigurationPath=/usr/safenet/lunaclient/ | ||
|
||
WORKDIR /app | ||
|
||
# Required for pkcs11js | ||
RUN apt-get update && apt-get install -y \ | ||
python3 \ | ||
make \ | ||
g++ \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY backend/package*.json ./ | ||
RUN npm ci --only-production | ||
|
||
COPY --from=backend-build /app . | ||
|
||
RUN mkdir frontend-build | ||
|
||
# Production stage | ||
FROM base AS production | ||
|
||
# Install necessary packages | ||
RUN apt-get update && apt-get install -y \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Infisical CLI | ||
RUN curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' | bash \ | ||
&& apt-get update && apt-get install -y infisical=0.31.1 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN groupadd -r -g 1001 nodejs && useradd -r -u 1001 -g nodejs non-root-user | ||
|
||
# Give non-root-user permission to update SSL certs | ||
RUN chown -R non-root-user /etc/ssl/certs | ||
RUN chown non-root-user /etc/ssl/certs/ca-certificates.crt | ||
RUN chmod -R u+rwx /etc/ssl/certs | ||
RUN chmod u+rw /etc/ssl/certs/ca-certificates.crt | ||
RUN chown non-root-user /usr/sbin/update-ca-certificates | ||
RUN chmod u+rx /usr/sbin/update-ca-certificates | ||
|
||
## set pre baked keys | ||
ARG POSTHOG_API_KEY | ||
ENV NEXT_PUBLIC_POSTHOG_API_KEY=$POSTHOG_API_KEY \ | ||
BAKED_NEXT_PUBLIC_POSTHOG_API_KEY=$POSTHOG_API_KEY | ||
ARG INTERCOM_ID=intercom-id | ||
ENV NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID \ | ||
BAKED_NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID | ||
ARG CAPTCHA_SITE_KEY | ||
ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=$CAPTCHA_SITE_KEY \ | ||
BAKED_NEXT_PUBLIC_CAPTCHA_SITE_KEY=$CAPTCHA_SITE_KEY | ||
|
||
WORKDIR / | ||
|
||
COPY --from=backend-runner /app /backend | ||
|
||
COPY --from=frontend-runner /app ./backend/frontend-build | ||
|
||
ENV PORT 8080 | ||
ENV HOST=0.0.0.0 | ||
ENV HTTPS_ENABLED false | ||
ENV NODE_ENV production | ||
ENV STANDALONE_BUILD true | ||
ENV STANDALONE_MODE true | ||
ENV ChrystokiConfigurationPath=/usr/safenet/lunaclient/ | ||
|
||
WORKDIR /backend | ||
|
||
ENV TELEMETRY_ENABLED true | ||
|
||
EXPOSE 8080 | ||
EXPOSE 443 | ||
|
||
USER non-root-user | ||
|
||
CMD ["./standalone-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.