-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and docker-compose.yml for Docker setup
- Loading branch information
1 parent
482599a
commit 33b32ea
Showing
5 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
UID=1000 | ||
GID=1000 | ||
USER_NAME=ubuntu | ||
GROUP_NAME=ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
############################################################## | ||
## Stage 1 - Go Build | ||
############################################################## | ||
|
||
FROM golang:latest AS builder | ||
WORKDIR /opt | ||
COPY . . | ||
RUN go build -o app . | ||
|
||
############################################################# | ||
## Stage 2 - Application Setup | ||
############################################################## | ||
FROM ubuntu:22.04 | ||
ARG UID=0 | ||
ARG GID=0 | ||
ARG USER=root | ||
ARG GROUP=root | ||
#------------------------------------------------------------- | ||
RUN apt-get update | ||
RUN apt-get install ca-certificates -y | ||
#------------------------------------------------------------- | ||
# User Set | ||
RUN if [ "${USER}" != "root" ]; then \ | ||
groupadd -g ${GID} ${GROUP} && \ | ||
useradd -m -u ${UID} -g ${GID} -s /bin/bash ${USER}; \ | ||
fi | ||
#------------------------------------------------------------- | ||
# Copy App and Web | ||
RUN mkdir -p /app/log | ||
RUN chown -R ${USER}:${GROUP} /app | ||
USER ${USER} | ||
COPY --from=builder --chown=${USER}:${GROUP} /opt/app /app/app | ||
COPY --from=builder --chown=${USER}:${GROUP} /opt/web /app/web | ||
#------------------------------------------------------------- | ||
# Add entrypoint script | ||
COPY --chown=${USER}:${GROUP} entrypoint.sh /app/entrypoint.sh | ||
RUN chmod +x /app/entrypoint.sh | ||
#------------------------------------------------------------- | ||
WORKDIR /app | ||
EXPOSE 3300 | ||
ENTRYPOINT ["/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
services: | ||
app: | ||
image: m-cmp/data-manager:latest | ||
container_name: mcmp-dm-web | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
UID: ${UID:-0} | ||
GID: ${GID:-0} | ||
USER: ${USER_NAME:-root} | ||
GROUP: ${GROUP_NAME:-root} | ||
WEB_DIR : ${WEB_DIR:-/web} | ||
APP_HOME: /app | ||
tty: true | ||
ports: | ||
- "3300:3300" | ||
restart : always | ||
volumes: | ||
- ./log:/app/log/ | ||
env_file: | ||
- .env | ||
################## | ||
## OPTIONAL ## | ||
################## | ||
## OPTIONAL LOGGING SETTINGS | ||
# logging: | ||
# driver: "json-file" | ||
# options: | ||
# max-size: "5m" # 로그 파일 최대 사이즈 | ||
# max-file: "10" # 로그 파일 최대 수 | ||
|
||
## OPTIONAL RESOURCE LIMITS | ||
# deploy: | ||
# resources: | ||
# limits: | ||
# cpus: "0.50" # 최대 CPU 사용량: 0.5 (50% of a single CPU core) | ||
# memory: "512M" # 최대 메모리 사용량: 512MB | ||
# reservations: | ||
# cpus: "0.25" # 예약된 최소 CPU 사용량: 0.25 (25% of a single CPU core) | ||
# memory: "256M" # 예약된 최소 메모리 사용량: 256MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
# Execute the main application | ||
exec /app/app server --allow-ip 0.0.0.0/0 --port 3300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters