Skip to content
Merged
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
16 changes: 13 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,20 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set Image Tag
id: set-image-tag
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_ENV
echo "Using image tag: ${GITHUB_SHA}"
else
echo "IMAGE_TAG=dev-${GITHUB_SHA}" >> $GITHUB_ENV
echo "Using image tag: dev-${GITHUB_SHA}"
fi

- name: Build and Push Docker Image
env:
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
IMAGE_TAG: ${{ github.sha }}
LATEST_TAG: latest
run: |
docker build -t $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG .
Expand Down Expand Up @@ -88,11 +98,11 @@ jobs:
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
IMAGE_TAG=${{ github.sha }}
echo "Updating production manifest..."
sed -i 's|image: .*$|image: '"${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ github.sha }}"'|g' ./overlays/prod/patch-app-deployment.yaml
sed -i "s|image: .*$|image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${IMAGE_TAG}|g" ./overlays/prod/patch-app-deployment.yaml
else
IMAGE_TAG=dev-${{ github.sha }}
echo "Updating development manifest..."
sed -i 's|image: .*$|image: '"${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ github.sha }}"'|g' ./overlays/dev/patch-app-deployment.yaml
sed -i "s|image: .*$|image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${IMAGE_TAG}|g" ./overlays/dev/patch-app-deployment.yaml
fi

- name: Commit and push changes if necessary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cinebox.security.config;
package cinebox.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/cinebox/common/config/FilterConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cinebox.common.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

@Bean
public FilterRegistrationBean<RequestMethodLoggingFilter> loggingFilter() {
FilterRegistrationBean<RequestMethodLoggingFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new RequestMethodLoggingFilter());
registrationBean.addUrlPatterns("/*");
return registrationBean;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cinebox.security.config;
package cinebox.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cinebox.common.config;

import java.io.IOException;

import org.slf4j.MDC;

import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;

public class RequestMethodLoggingFilter implements Filter {

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {

HttpServletRequest httpRequest = (HttpServletRequest) request;
try {
MDC.put("requestMethod", httpRequest.getMethod());
chain.doFilter(request, response);
} finally {
MDC.remove("requestMethod");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cinebox.security.config;
package cinebox.common.config;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cinebox.security.config;
package cinebox.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@
<appender name="JSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"app":"cinebox","env":"prod"}</customFields>
<appendLineSeparator>true</appendLineSeparator>
</encoder>
<async>true</async>
<queueSize>1024</queueSize>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/cinebox/app.log</file>
<createParentDirectory>true</createParentDirectory>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/var/log/cinebox/app-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{ISO8601} [%thread] [%mdc{requestMethod}] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="JSON"/>
<appender-ref ref="FILE"/>
</root>
</configuration>