Add Dockerfile + nginx conf + add woodpecker CI file

This commit is contained in:
Joris Bertomeu
2024-09-26 15:57:25 +02:00
parent 023f263361
commit db1390e7a6
4 changed files with 132 additions and 0 deletions

49
.dockerignore Normal file
View File

@@ -0,0 +1,49 @@
# Use yarn.lock instead
package-lock.json
# Logs
logs
*.log
npm-debug.log*
# Documentation
docs
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Upload dir
[Uu]ploads/
# Docker compose spec
docker-compose.*

34
.woodpecker.yaml Normal file
View File

@@ -0,0 +1,34 @@
# Build and publish Docker images for multiple architectures.
#
# Pushing an image to codeberg's container registry
# The package owner will be the repo owner.
#
# This config also shows usage of yaml aliases and
# was taken from https://codeberg.org/6543/docker-images/src/commit/37e29c227717c1c07d2776cddcf14725bf952875/.woodpecker/hello.yml
when:
branch: main
event: [push]
variables:
- &file Dockerfile
- &repo 192.168.1.230:5000/bertomlab/crawlflix/front
steps:
publish:
image: woodpeckerci/plugin-docker-buildx
settings:
dockerfile: *file
insecure: true
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64
repo: *repo
tags:
- latest
- ${CI_COMMIT_SHA}
username:
from_secret: docker_registry_username
password:
from_secret: docker_password
username: ${CI_REPO_OWNER}
password:
from_secret: cb_token

20
Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# Build stage
FROM node:22 AS crawlflix-front-build
WORKDIR /app
# Add full context
ARG CONFIGURATION=production
ENV CONFIGURATION $CONFIGURATION
ARG build_number=0
ENV BUILD_NUMBER $build_number
COPY . .
# Install deps
RUN npm install -f
RUN npm install -g @angular/cli
RUN echo "export const version = { number: '${BUILD_NUMBER}' }" > ./src/version.ts
# Build dist
RUN ng build --configuration=${CONFIGURATION} --output-hashing=all
# Create stage
FROM nginx:latest
COPY --from=crawlflix-front-build /app/dist/crawlflix/browser/ /usr/share/nginx/html/
COPY /nginx.conf /etc/nginx/conf.d/default.conf

29
nginx.conf Normal file
View File

@@ -0,0 +1,29 @@
server {
listen 80;
sendfile on;
server_tokens off;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
# location /api/ {
# proxy_pass http://dockerprod2.icssophia.local:24600/;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
}