diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..164cfb4 --- /dev/null +++ b/.dockerignore @@ -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.* diff --git a/.woodpecker.yaml b/.woodpecker.yaml new file mode 100644 index 0000000..2566e88 --- /dev/null +++ b/.woodpecker.yaml @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ecf5bc0 --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..022d2d4 --- /dev/null +++ b/nginx.conf @@ -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; + # } +} \ No newline at end of file