-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Build and Push on GitHub Container Registry (#31)
* Feature/docker setup (#30) * feat: add docker files * fix: docker compose * feat: docker CI pipeline * fix: update actions version * fix: docker commands --------- Co-authored-by: Francesco <[email protected]>
- Loading branch information
1 parent
b97612e
commit 4e3fc2e
Showing
22 changed files
with
462 additions
and
58 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,12 @@ | ||
DATABASE_TYPE= | ||
DATABASE_HOST= | ||
DATABASE_PORT= | ||
DATABASE_USERNAME= | ||
DATABASE_PASSWORD= | ||
DATABASE_NAME= | ||
DATABASE_SYNCHRONIZE= | ||
AUTH0_ISSUER_URL= | ||
AUTH0_AUDIENCE= | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
GOOGLE_REDIRECT_URI= |
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,3 @@ | ||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= | ||
POSTGRES_DB= |
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,4 @@ | ||
VITE_AUTH0_DOMAIN= | ||
VITE_AUTH0_CLIENTID= | ||
VITE_AUTH0_AUDIENCE= | ||
VITE_BASE_URL= |
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,67 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Test"] | ||
types: [completed] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | ||
WEB_IMAGE=ghcr.io/$OWNER/hkrecruitment-web | ||
API_IMAGE=ghcr.io/$OWNER/hkrecruitment-api | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
WEB_TAGS="$WEB_IMAGE:$VERSION,$WEB_IMAGE:latest" | ||
API_TAGS="$API_IMAGE:$VERSION,$API_IMAGE:latest" | ||
elif [[ $GITHUB_REF == refs/heads/main ]]; then | ||
VERSION=main-$(git rev-parse --short ${{ github.sha }}) | ||
WEB_TAGS="$WEB_IMAGE:$VERSION,$WEB_IMAGE:latest" | ||
API_TAGS="$API_IMAGE:$VERSION,$API_IMAGE:latest" | ||
elif [[ $GITHUB_REF == refs/heads/dev ]]; then | ||
VERSION=dev-$(git rev-parse --short ${{ github.sha }}) | ||
WEB_TAGS="$WEB_IMAGE:$VERSION,$WEB_IMAGE:test" | ||
API_TAGS="$API_IMAGE:$VERSION,$API_IMAGE:test" | ||
else | ||
VERSION=$(git rev-parse --short ${{ github.sha }}) | ||
WEB_TAGS="$WEB_IMAGE:$VERSION" | ||
API_TAGS="$API_IMAGE:$VERSION" | ||
fi | ||
echo "::set-output name=web_tags::$WEB_TAGS" | ||
echo "::set-output name=api_tags::$API_TAGS" | ||
shell: bash | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push web image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile_web | ||
push: true | ||
tags: ${{ steps.prep.outputs.web_tags }} | ||
|
||
- name: Build and push api image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile_api | ||
push: true | ||
tags: ${{ steps.prep.outputs.api_tags }} |
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,35 @@ | ||
# Use Node.js 20 | ||
FROM node:20 | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
COPY api/package.json api/ | ||
COPY shared/package.json shared/ | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# Install pnpm 8 | ||
RUN npm install -g pnpm@8 | ||
|
||
# Install dependencies | ||
RUN pnpm install | ||
|
||
# Copy all files to the container | ||
COPY . . | ||
|
||
# Check formatting | ||
RUN pnpm run format-check | ||
|
||
# Build the app | ||
RUN pnpm run build:api | ||
|
||
# Expose the port | ||
EXPOSE 3000 | ||
|
||
# Start the app | ||
CMD ["pnpm", "preview:api"] | ||
|
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,36 @@ | ||
# Use Node.js 20 | ||
FROM node:20 | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
COPY frontend/package.json frontend/ | ||
COPY api/package.json api/ | ||
COPY shared/package.json shared/ | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# Install pnpm 8 | ||
RUN npm install -g pnpm@8 | ||
|
||
# Install dependencies | ||
RUN pnpm install | ||
|
||
# Copy all files to the container | ||
COPY . . | ||
|
||
# Check formatting | ||
RUN pnpm run format-check | ||
|
||
# Build the app | ||
RUN pnpm run build:web | ||
|
||
# Expose the port | ||
EXPOSE 5173 | ||
|
||
# Start the app | ||
CMD ["pnpm", "dev: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,9 @@ | ||
services: | ||
db: | ||
image: postgres:latest | ||
environment: | ||
- POSTGRES_USER=hkrecruitment | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=hkrecruitment | ||
ports: | ||
- '5432:5432' |
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,9 +1,30 @@ | ||
services: | ||
db: | ||
image: postgres:latest | ||
environment: | ||
- POSTGRES_USER=hkrecruitment | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=hkrecruitment | ||
env_file: | ||
- .env_db | ||
ports: | ||
- '5432:5432' | ||
|
||
|
||
web: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile_web | ||
env_file: | ||
- .env_web | ||
ports: | ||
- '5173:5173' | ||
depends_on: | ||
- db | ||
|
||
api: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile_api | ||
env_file: | ||
- .env_api | ||
ports: | ||
- '3000:3000' | ||
depends_on: | ||
- db |
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.