Skip to content

Commit

Permalink
Merge pull request #419 from afaneca/develop
Browse files Browse the repository at this point in the history
7.4.1
  • Loading branch information
afaneca authored Feb 11, 2025
2 parents 3e4792e + bf630bb commit 60a25bf
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Dependencies
node_modules
npm-debug.log
yarn-debug.log
yarn-error.log
.pnpm-debug.log

# Version control
.git
.gitignore
.gitattributes

# Environment files
.env*
*.env
.env.local
.env.*.local

# IDE
.vscode
.idea
*.sublime-*
.DS_Store

# Testing
test
__tests__
coverage
*.test.js
*.spec.js

# Docker
.dockerignore
Dockerfile
docker-compose*

# Build outputs
dist
build
*.log

# Documentation
*.md
docs
README*
CHANGELOG*
LICENSE*
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: [afaneca] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: afaneca # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
92 changes: 92 additions & 0 deletions .github/workflows/build-container-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
tags: [ '*.*.*' ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: afaneca/myfin


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.4.2'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
no-cache: true


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Build stage
FROM node:20-alpine AS build

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy source code
COPY . .

ARG VITE_MYFIN_BASE_API_URL
ENV VITE_MYFIN_BASE_API_URL="myfin-api-url-placeholder"

# Build the app
RUN npm run build

# Serve stage
FROM nginx:alpine

WORKDIR /usr/share/nginx/html

# Add metadata
LABEL maintainer="José Valdiviesso <[email protected]>"
LABEL author="José Valdiviesso <[email protected]>"
LABEL version="7.4.1"
LABEL description="MyFin Frontend Application"
LABEL org.opencontainers.image.authors="José Valdiviesso <[email protected]>"
LABEL org.opencontainers.image.version="7.4.1"
LABEL org.opencontainers.image.title="MyFin Frontend"
LABEL org.opencontainers.image.description="Web frontend for the personal finances platform that'll help you budget, keep track of your income/spending and forecast your financial future."
LABEL org.opencontainers.image.source="https://github.com/afaneca/myfin"

# Copy built files from build stage
COPY --from=build /app/dist /usr/share/nginx/html

# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Create startup script
RUN echo '#!/bin/sh' > /start.sh && \
echo 'find /usr/share/nginx/html -type f -name "*.js" -exec sed -i "s|myfin-api-url-placeholder|$VITE_MYFIN_BASE_API_URL|g" {} +' >> /start.sh && \
echo "nginx -g 'daemon off;'" >> /start.sh && \
chmod +x /start.sh

# Expose port 80
EXPOSE 80

# Healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:80/ | grep -q '<title>MyFin</title>' || exit 1

# Start nginx
CMD ["/start.sh"]
61 changes: 61 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
services:
db:
image: mariadb
restart: always
environment:
MARIADB_ROOT_PASSWORD: myfinrootpassword
MARIADB_DATABASE: myfin
MARIADB_USER: myfin
MARIADB_PASSWORD: myfinpassword
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3

myfin-api:
image: ghcr.io/afaneca/myfin-api:latest
container_name: myfin-api
restart: unless-stopped
ports:
- "8081:3001"
environment:
# Database Configuration
- DB_NAME=myfin
- DB_USER=myfin
- DB_PW=myfinpassword
- DB_PORT=3306
- DB_HOST=db
# Email Configuration
- SMTP_HOST=
- SMTP_PORT=
- SMTP_SECURE=
- SMTP_USER=
- SMTP_PASSWORD=
- SMTP_FROM=
# Application Configuration
- PORT=3001
- LOGGING=true
- BYPASS_SESSION_CHECK=false
- ENABLE_USER_SIGNUP=true
depends_on:
db:
condition: service_healthy

myfin-frontend:
image: ghcr.io/afaneca/myfin:latest
container_name: myfin-frontend
restart: unless-stopped
ports:
- "8080:80"
depends_on:
myfin-api:
condition: service_healthy
environment:
- VITE_MYFIN_BASE_API_URL=http://localhost:8081

volumes:
db_data:
16 changes: 16 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "myfin-web",
"private": true,
"version": "7.3.0",
"version": "7.4.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down

0 comments on commit 60a25bf

Please sign in to comment.