mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
This commit is contained in:
parent
0b51ccfd40
commit
8937a42887
6 changed files with 7210 additions and 10211 deletions
38
.github/workflows/build-docker.yaml
vendored
38
.github/workflows/build-docker.yaml
vendored
|
|
@ -1,38 +0,0 @@
|
|||
name: Build and Push Docker
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- prod
|
||||
|
||||
env:
|
||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
#- name: Set up Tailscale
|
||||
# uses: tailscale/github-action@v2
|
||||
# with:
|
||||
# authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/soc-site:${{ BRANCH_NAME }}
|
||||
81
.github/workflows/build-image.yaml
vendored
Normal file
81
.github/workflows/build-image.yaml
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
name: Build Docker image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['dev', 'prod']
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set environment variables
|
||||
id: set_env_vars
|
||||
env:
|
||||
SOC_ENV_DEV: ${{ secrets.SOC_ENV_DEV }}
|
||||
SOC_ENV_PROD: ${{ secrets.SOC_ENV_PROD }}
|
||||
DATABASE_URL_DEV: ${{ secrets.SOC_MARIADB_URL_DEV }}
|
||||
DATABASE_URL_PROD: ${{ secrets.SOC_MARIADB_URL_PROD }}
|
||||
run: |
|
||||
if [ "${GITHUB_REF_NAME}" = "dev" ]; then
|
||||
echo "SOC_ENV=${SOC_ENV_DEV}" >> $GITHUB_ENV
|
||||
echo "DATABASE_URL=${DATABASE_URL_DEV}" >> $GITHUB_ENV
|
||||
echo "ENVIRONMENT=dev" >> $GITHUB_ENV
|
||||
elif [ "${GITHUB_REF_NAME}" = "prod" ]; then
|
||||
echo "SOC_ENV=${SOC_ENV_PROD}" >> $GITHUB_ENV
|
||||
echo "DATABASE_URL=${DATABASE_URL_PROD}" >> $GITHUB_ENV
|
||||
echo "ENVIRONMENT=prod" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Prepare environment files
|
||||
run: |
|
||||
# Create .env.runner with current environment variables
|
||||
echo "SOC_ENV=${SOC_ENV}" > .env.runner
|
||||
echo "DATABASE_URL=${DATABASE_URL}" >> .env.runner
|
||||
|
||||
# Create .env.docker with a dummy DATABASE_URL for build (no network access needed)
|
||||
echo "SOC_ENV=${SOC_ENV}" > .env.docker
|
||||
echo "DATABASE_URL=mysql://dummy:dummy@localhost:3306/dummy" >> .env.docker
|
||||
|
||||
# Create .env.runtime with the real database URL for runtime
|
||||
echo "SOC_ENV=${SOC_ENV}" > .env.runtime
|
||||
echo "DATABASE_URL=$(echo "${DATABASE_URL}" | sed 's#mariadb:3306#behemoth.cerberus-alligator.ts.net:3306#g')" >> .env.runtime
|
||||
|
||||
# Debug: Show what files were created
|
||||
echo "=== .env.runner ==="
|
||||
cat .env.runner
|
||||
echo "=== .env.docker ==="
|
||||
cat .env.docker
|
||||
echo "=== .env.runtime ==="
|
||||
cat .env.runtime
|
||||
echo "=== Directory listing ==="
|
||||
ls -la
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'latest'
|
||||
check-latest: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Tailscale
|
||||
uses: tailscale/github-action@v3
|
||||
with:
|
||||
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
|
||||
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
|
||||
tags: tag:ci
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: soc-site:${{ github.ref_name }}
|
||||
network: host
|
||||
build-args: |
|
||||
ENVIRONMENT=${{ env.ENVIRONMENT }}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -21,8 +21,7 @@ yarn-error.log*
|
|||
pnpm-debug.log*
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
.env*
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
24
Dockerfile
24
Dockerfile
|
|
@ -1,19 +1,31 @@
|
|||
FROM node:24-alpine AS builder
|
||||
FROM node:24-alpine AS build-deps
|
||||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
FROM node:24-alpine AS build
|
||||
ARG GIT_BRANCH
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN yarn install --frozen-lockfile
|
||||
COPY --from=build-deps /app/node_modules ./node_modules
|
||||
COPY .env.docker .env
|
||||
RUN yarn build
|
||||
|
||||
FROM node:24-alpine AS dependencies
|
||||
FROM node:24-alpine AS prod-deps
|
||||
WORKDIR /app
|
||||
COPY package.json yarn.lock ./
|
||||
RUN corepack enable
|
||||
RUN yarn install --production --frozen-lockfile
|
||||
|
||||
FROM node:24-alpine AS runner
|
||||
ARG GIT_BRANCH
|
||||
WORKDIR /app
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=80
|
||||
EXPOSE 80
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
||||
COPY --from=build /app/dist ./dist
|
||||
COPY --from=prod-deps /app/node_modules ./node_modules
|
||||
COPY .env.runner .env
|
||||
COPY package.json yarn.lock
|
||||
CMD ["yarn prisma:migrate", "node ./dist/server/entry.mjs"]
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "yarn run prisma:build && astro build",
|
||||
"build": "yarn prisma:build && astro build",
|
||||
"prisma:migrate": "prisma migrate deploy && tsx ./prisma/migrate.ts",
|
||||
"prisma:build": "yarn prisma:migrate && prisma generate --sql"
|
||||
"prisma:build": "prisma generate --sql"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ag-grid-community/locale": "^33.3.2",
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
"@parcel/watcher": "^2.4.1",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"concurrently": "^8.2.2",
|
||||
"daisyui": "^5.0.43",
|
||||
"eslint": "^9.11.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-astro": "^1.2.4",
|
||||
|
|
@ -54,5 +55,5 @@
|
|||
"prettier": "^3.3.3",
|
||||
"prettier-config-standard": "^7.0.0"
|
||||
},
|
||||
"packageManager": "yarn@4.9.1"
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue