Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build the Docker image
# ¡Línea corregida para usar la ruta CI/Dockerfile y el contexto CI/!
run: docker build --platform linux --tag ${{ secrets.DOCKERHUB_USERNAME }}/backenddockerci:latest -f CI/Dockerfile CI/

- name: Push the Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/backenddockerci:latest
31 changes: 31 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Docker Test

on:
push:
branches:
- main

jobs:
docker-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Run Docker container
run: |
docker run -d --name testcontainer alpine tail -f /dev/null

- name: Run tests
run: |
docker exec testcontainer /bin/sh -c "
echo 'Ejecutando pruebas...';
cd home
mkdir amin
cd amin
printf 'Este es el contenido del archivo.\nPuede incluir varias líneas.\n' > ejemplo.txt
ls -a || exit 1
"
11 changes: 11 additions & 0 deletions BuildContext/ApiNode/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:21

WORKDIR /app

COPY package*.json ./
RUN npm install
COPY src/ src/
EXPOSE 3000

# Comando para ejecutar la aplicación
CMD ["node", "src/index.js"]
Empty file.
14 changes: 14 additions & 0 deletions BuildContext/ApiNode/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import express from 'express';
import { taskRouter } from './task.js';

const port = process.env.PORT || 3000;
const app = express();

app.use('/tasks', taskRouter);
app.use('*', (_, res) => {
res.redirect('/api-docs');
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Loading