-
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.
Merge pull request #19 from yunkon-kim/yunkon-kim-240214-1
Add Dockerfile
- Loading branch information
Showing
17 changed files
with
129 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,33 @@ | ||
.github/ | ||
docs/ | ||
|
||
# Example files for tofu and infrastructure configurations (e.g. .tf files) | ||
examples/ | ||
|
||
# Terrafrom files | ||
*.tfstate | ||
*.tfstate.backup | ||
*.tfvars | ||
.terraform/ | ||
.terraform.lock.hcl | ||
|
||
# Secret files | ||
*credential* | ||
|
||
# Binaries | ||
pkg/poc-mc-net-tf | ||
pkg/poc-mc-net-tf-arm | ||
cmd/poc-mc-net-tf/poc-mc-net-tf | ||
|
||
# Log files | ||
log/ | ||
logs/ | ||
*.log | ||
|
||
# Files for tofu and infrastructure configurations | ||
!.tofu/ | ||
.tofu/* | ||
!.tofu/secrets | ||
.tofu/secrets/* | ||
!.tofu/secrets/.keep | ||
!.tofu/template-tfs |
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
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,74 @@ | ||
############################################################## | ||
## Stage 1 - Go Build | ||
############################################################## | ||
|
||
# Using a specific version of golang based on alpine for building the application | ||
FROM golang:1.21.4-alpine AS builder | ||
|
||
# Installing necessary packages | ||
# sqlite-libs and sqlite-dev for SQLite support | ||
# build-base for common build requirements | ||
RUN apk add --no-cache sqlite-libs sqlite-dev build-base | ||
|
||
# Copying only necessary files for the build | ||
COPY . /go/src/github.com/cloud-barista/poc-mc-net-tf | ||
WORKDIR /go/src/github.com/cloud-barista/poc-mc-net-tf | ||
# COPY go.mod go.sum go.work go.work.sum ./ | ||
RUN go mod download | ||
# COPY .tofu ./.tofu | ||
# COPY cmd ./cmd | ||
# COPY conf ./conf | ||
# COPY pkg ./pkg | ||
|
||
# Building the Go application with specific flags | ||
# Note - "make prod" executes the command, | ||
# CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o poc-mc-net-tf" | ||
RUN make prod | ||
|
||
############################################################# | ||
## Stage 2 - Application Setup | ||
############################################################## | ||
|
||
# Using the latest Ubuntu image for the production stage | ||
FROM ubuntu:latest as prod | ||
|
||
# Setting the working directory for the application | ||
WORKDIR /app | ||
|
||
# Copying necessary files from the builder stage to the production stage | ||
# Assets, scripts, and configuration files are copied excluding credentials.conf | ||
# which should be specified in .dockerignore | ||
COPY --from=builder /go/src/github.com/cloud-barista/poc-mc-net-tf/.tofu/ /app/.tofu/ | ||
COPY --from=builder /go/src/github.com/cloud-barista/poc-mc-net-tf/conf/ /app/conf/ | ||
COPY --from=builder /go/src/github.com/cloud-barista/poc-mc-net-tf/scripts/ /app/scripts/ | ||
COPY --from=builder /go/src/github.com/cloud-barista/poc-mc-net-tf/cmd/poc-mc-net-tf/poc-mc-net-tf /app/ | ||
|
||
RUN ./scripts/install-tofu.sh | ||
|
||
# Setting various environment variables required by the application | ||
ENV POCMCNETTF_ROOT=/app \ | ||
LOGFILE_PATH=poc-mc-net-tf.log \ | ||
LOGFILE_MAXSIZE=10 \ | ||
LOGFILE_MAXBACKUPS=3 \ | ||
LOGFILE_MAXAGE=30 \ | ||
LOGFILE_COMPRESS=false \ | ||
LOGLEVEL=debug \ | ||
LOGWRITER=both \ | ||
NODE_ENV=development \ | ||
DB_URL=localhost:3306 \ | ||
DB_DATABASE=poc_mc_net_tf \ | ||
DB_USER=poc_mc_net_tf \ | ||
DB_PASSWORD=poc_mc_net_tf \ | ||
API_ALLOW_ORIGINS=* \ | ||
API_AUTH_ENABLED=true \ | ||
API_USERNAME=default \ | ||
API_PASSWORD=default \ | ||
AUTOCONTROL_DURATION_MS=10000 \ | ||
SELF_ENDPOINT=localhost:8888 \ | ||
API_DOC_PATH=/app/pkg/api/rest/docs/swagger.json | ||
|
||
# Setting the entrypoint for the application | ||
ENTRYPOINT [ "/app/poc-mc-net-tf" ] | ||
|
||
# Exposing the port that the application will run on | ||
EXPOSE 8888 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,20 @@ | ||
# Ensure that your system is up to date | ||
apt update -y | ||
|
||
# Ensure that you have installed the dependencies, such as `gnupg`, `software-properties-common`, `curl`, and unzip packages. | ||
apt install -y curl | ||
|
||
# Download the installer script: | ||
curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh | ||
# Alternatively: wget --secure-protocol=TLSv1_2 --https-only https://get.opentofu.org/install-opentofu.sh -O install-opentofu.sh | ||
|
||
# Give it execution permissions: | ||
chmod +x install-opentofu.sh | ||
|
||
# Please inspect the downloaded script | ||
|
||
# Run the installer: | ||
./install-opentofu.sh --install-method deb | ||
|
||
# Remove the installer: | ||
rm install-opentofu.sh |