-
Notifications
You must be signed in to change notification settings - Fork 1
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 #374 from bounswe/feature/cont-deploy
- Loading branch information
Showing
21 changed files
with
1,445 additions
and
1,632 deletions.
There are no files selected for viewing
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,65 @@ | ||
alerts: | ||
- rule: DEPLOYMENT_FAILED | ||
- rule: DOMAIN_FAILED | ||
features: | ||
- buildpack-stack=ubuntu-22 | ||
ingress: | ||
rules: | ||
- component: | ||
name: backend | ||
preserve_path_prefix: true | ||
match: | ||
path: | ||
prefix: /api | ||
- component: | ||
name: web | ||
match: | ||
path: | ||
prefix: / | ||
name: programming-languages-forum | ||
region: fra | ||
databases: | ||
- cluster_name: programmingforum | ||
db_name: programming-languages | ||
db_user: doadmin | ||
engine: MYSQL | ||
name: programmingforum | ||
production: true | ||
version: "8" | ||
services: | ||
- name: backend | ||
envs: | ||
- key: DB_HOST | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.HOSTNAME}:${db.PORT} | ||
- key: DB_NAME | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.DATABASE} | ||
- key: DB_USER | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.USERNAME} | ||
- key: DB_PASSWORD | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.PASSWORD} | ||
- key: SPRING_PROFILES_ACTIVE | ||
scope: RUN_AND_BUILD_TIME | ||
value: docker | ||
http_port: 8080 | ||
image: | ||
deploy_on_push: | ||
enabled: true | ||
registry_type: DOCR | ||
repository: backend | ||
tag: latest | ||
instance_count: 1 | ||
instance_size_slug: professional-xs | ||
- name: web | ||
http_port: 80 | ||
image: | ||
deploy_on_push: | ||
enabled: true | ||
registry_type: DOCR | ||
repository: web | ||
tag: latest | ||
instance_count: 1 | ||
instance_size_slug: professional-xs |
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,65 @@ | ||
alerts: | ||
- rule: DEPLOYMENT_FAILED | ||
- rule: DOMAIN_FAILED | ||
features: | ||
- buildpack-stack=ubuntu-22 | ||
ingress: | ||
rules: | ||
- component: | ||
name: backend | ||
preserve_path_prefix: true | ||
match: | ||
path: | ||
prefix: /api | ||
- component: | ||
name: web | ||
match: | ||
path: | ||
prefix: / | ||
name: programming-languages-staging | ||
region: fra | ||
databases: | ||
- name: programming-languages | ||
engine: MYSQL | ||
version: "8.0" | ||
production: true | ||
cluster_name: programmingforum-staging | ||
db_name: programmingforum | ||
db_user: programmingforum | ||
services: | ||
- envs: | ||
- key: DB_HOST | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.HOSTNAME}:${db.PORT} | ||
- key: DB_NAME | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.DATABASE} | ||
- key: DB_USER | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.USERNAME} | ||
- key: DB_PASSWORD | ||
scope: RUN_AND_BUILD_TIME | ||
value: ${db.PASSWORD} | ||
- key: SPRING_PROFILES_ACTIVE | ||
scope: RUN_AND_BUILD_TIME | ||
value: docker | ||
http_port: 8080 | ||
image: | ||
deploy_on_push: | ||
enabled: true | ||
registry_type: DOCR | ||
repository: backend | ||
tag: staging | ||
instance_count: 1 | ||
instance_size_slug: professional-xs | ||
name: backend | ||
- http_port: 80 | ||
image: | ||
deploy_on_push: | ||
enabled: true | ||
registry_type: DOCR | ||
repository: web | ||
tag: staging | ||
instance_count: 1 | ||
instance_size_slug: professional-xs | ||
name: web |
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,44 @@ | ||
name: Front-End CI | ||
|
||
on: | ||
push: | ||
paths: | ||
- "frontend/**" | ||
- ".github/workflows/frontend_test.yml" | ||
pull_request: | ||
branches: | ||
- main | ||
- staging | ||
|
||
jobs: | ||
test: | ||
name: Frontend Tests | ||
runs-on: ubuntu-latest | ||
env: | ||
working-directory: frontend | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Enable corepack | ||
run: corepack enable | ||
|
||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --immutable | ||
|
||
- name: Run formatter | ||
run: yarn format | ||
|
||
- name: Run linter | ||
run: yarn lint | ||
|
||
- name: Run tests | ||
run: yarn test |
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,45 @@ | ||
name: Deploy Production | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Install doctl. | ||
- name: Install doctl | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DO_ACCESS_TOKEN }} | ||
|
||
# Build a Docker image of your application in your registry and tag the image with the $GITHUB_SHA. | ||
- name: Build backend image | ||
run: docker build -t registry.digitalocean.com/programming-languages/backend:$(echo $GITHUB_SHA | head -c7) ./backend | ||
|
||
- name: Build web image | ||
run: docker build -t registry.digitalocean.com/programming-languages/web:$(echo $GITHUB_SHA | head -c7) ./frontend | ||
|
||
- name: Log in to DigitalOcean Container Registry with short-lived credentials | ||
run: doctl registry login --expiry-seconds 1200 | ||
|
||
# Push the Docker image to your registry. | ||
|
||
- name: Push backend image | ||
run: docker push registry.digitalocean.com/programming-languages/backend:$(echo $GITHUB_SHA | head -c7) | ||
|
||
- name: Push web image | ||
run: docker push registry.digitalocean.com/programming-languages/web:$(echo $GITHUB_SHA | head -c7) | ||
|
||
# TODO: push to latest | ||
|
||
- name: Push backend image | ||
run: docker push registry.digitalocean.com/programming-languages/backend:latest | ||
|
||
- name: Push web image | ||
run: docker push registry.digitalocean.com/programming-languages/web:latest |
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 |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
personal_work/ | ||
|
||
node_modules | ||
|
||
.yarn/install-state.gz |
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 @@ | ||
nodeLinker: node-modules |
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,30 @@ | ||
# Use a base image with Maven to build the Spring Boot application | ||
FROM maven:3.8.4 AS builder | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the Maven project file | ||
COPY pom.xml . | ||
|
||
# Download dependencies | ||
RUN mvn -B dependency:go-offline | ||
|
||
# Copy the entire project source | ||
COPY src ./src | ||
|
||
# Build the application JAR (Skip tests since they require db) | ||
RUN mvn -B package -DskipTests | ||
|
||
# Use a lighter base image for the runtime environment | ||
FROM openjdk:23-ea-17-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the JAR file from the previous stage | ||
COPY --from=builder /app/target/ProgrammingLanguagesForum*.jar ./ProgrammingLanguagesForum.jar | ||
|
||
EXPOSE 8080 | ||
# Command to run the application when the container starts | ||
CMD ["java", "-jar", "ProgrammingLanguagesForum.jar"] |
Empty file.
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
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,3 +1,4 @@ | ||
cd frontend | ||
yarn install --immutable | ||
yarn test run | ||
yarn lint-staged |
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 |
---|---|---|
|
@@ -89,5 +89,5 @@ | |
"prettier --write" | ||
] | ||
}, | ||
"packageManager": "yarn@4.2.2" | ||
"packageManager": "yarn@4.5.0" | ||
} |
Oops, something went wrong.