Skip to content

Commit

Permalink
Feature: Add cors configuration (#9)
Browse files Browse the repository at this point in the history
* feat: added cors config

* feat: refactor docker-compose.yml and added support for older versions.

* feat: added github action to build and publish new images

---------

Co-authored-by: Saúl Eiros <[email protected]>
  • Loading branch information
SaulEiros and Saúl Eiros authored Jul 28, 2024
1 parent 966612a commit 8f99fd5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

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

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

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: mreiros/album-explorer-backend:latest
8 changes: 8 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
backend:
container_name: album-explorer
image: mreiros/album-explorer-backend:latest
volumes:
- ./src:/app/src
ports:
- 8080:8080
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '3.7'

services:
backend:
container_name: album-explorer
build: .
image: mreiros/album-explorer-backend:latest
volumes:
- ./src:/app/src
ports:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sauleiros.albumexplorer.infra.adapters.input.rest

import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
@EnableWebMvc
class WebConfig : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
}
}

0 comments on commit 8f99fd5

Please sign in to comment.