Skip to content

Commit

Permalink
Build: preparing docker
Browse files Browse the repository at this point in the history
  • Loading branch information
acosta-leandro committed Jan 17, 2025
1 parent 621bdf0 commit 99d3ac7
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
.git
.gitignore
README.md
.env*
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Docker image

on:
push:
branches:
- main

permissions:
packages: write
contents: read

jobs:
Deploy:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Set up QEMU"
uses: "docker/setup-qemu-action@v3"

- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3"

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
file: ./Dockerfile
push: true
tags: "ghcr.io/compbio-fhs/compbio-home:latest"
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"editorconfig.editorconfig",
"vue.volar",
"wayou.vscode-todo-highlight"
],
"unwantedRecommendations": [
"octref.vetur",
"hookyqr.beautify",
"dbaeumer.jshint",
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true
}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:18-alpine as build-stage

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
RUN ls -la dist/spa

FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist/spa /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN ls -la /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Stop and remove existing containers
docker compose down

# Rebuild without cache
docker compose build --no-cache

# Start and follow logs
docker compose up --force-recreate
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'
services:
app:
build: .
ports:
- "81:80"
restart: unless-stopped
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
23 changes: 23 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;

# Enable directory listing for debugging
autoindex on;

location / {
try_files $uri $uri/ /index.html =404;
add_header Cache-Control "no-cache";
}

location /assets {
expires 1y;
add_header Cache-Control "public";
}

# Add error logging
error_log /var/log/nginx/error.log debug;
access_log /var/log/nginx/access.log;
}

0 comments on commit 99d3ac7

Please sign in to comment.