Skip to content

Commit 6211018

Browse files
authored
Merge pull request #67 from sir-gon/feature/production_ready
Feature/production ready
2 parents 74d3cc7 + 91c8d85 commit 6211018

File tree

6 files changed

+215
-22
lines changed

6 files changed

+215
-22
lines changed

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
<https://www.contributor-covenant.org/faq>. Translations are available at
128+
<https://www.contributor-covenant.org/translations>.

Dockerfile

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,107 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0.302-alpine3.19-amd64 AS base
44
ENV WORKDIR=/app
55
WORKDIR ${WORKDIR}
66

7+
RUN apk add --update --no-cache make
8+
79
###############################################################################
810
FROM base AS lint
911

1012
ENV WORKDIR=/app
1113
WORKDIR ${WORKDIR}
1214

13-
COPY ./docs ${WORKDIR}/docs
1415
RUN apk add --update --no-cache make nodejs npm
1516
RUN apk add --update --no-cache yamllint
1617

1718
RUN npm install -g --ignore-scripts markdownlint-cli
1819

19-
###############################################################################
20-
FROM base AS development
20+
# [!TIP] Use a bind-mount to "/app" to override following "copys"
21+
# for lint and test against "current" sources in this stage
2122

22-
RUN apk add --update --no-cache make
23+
# YAML sources
24+
COPY ./.github ${WORKDIR}/
25+
COPY ./compose.yaml ${WORKDIR}/
26+
27+
# Markdown sources
28+
COPY ./docs ${WORKDIR}/
29+
COPY ./README.md ${WORKDIR}/
30+
COPY ./LICENSE.md ${WORKDIR}/
31+
COPY ./CODE_OF_CONDUCT.md ${WORKDIR}/
32+
33+
# Code source
34+
COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp
35+
COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test
36+
COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln
37+
COPY ./Makefile ${WORKDIR}/
38+
39+
# code linting conf
40+
COPY ./.editorconfig ${WORKDIR}/
41+
42+
# markdownlint conf
43+
COPY ./.markdownlint.yaml ${WORKDIR}/
44+
45+
# yamllint conf
46+
COPY ./.yamllint ${WORKDIR}/
47+
COPY ./.yamlignore ${WORKDIR}/
2348

2449
###############################################################################
25-
FROM development AS builder
50+
FROM base AS development
2651

2752
COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp
53+
COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test
2854
COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln
2955
COPY ./Makefile ${WORKDIR}/
56+
57+
RUN make build
58+
RUN ls -alh
59+
60+
# CMD []
61+
###############################################################################
62+
FROM development AS builder
63+
64+
RUN dotnet publish --self-contained --runtime linux-musl-x64
3065
RUN ls -alh
3166

67+
CMD ["ls", "-alh"]
68+
3269
###############################################################################
3370
### In testing stage, can't use USER, due permissions issue
3471
## in github actions environment:
3572
##
3673
## https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions
3774
##
38-
FROM builder AS testing
75+
FROM development AS testing
3976

4077
ENV LOG_LEVEL=INFO
4178
ENV BRUTEFORCE=false
4279

4380
WORKDIR /app
4481

45-
COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test
4682
RUN ls -alh
4783

48-
CMD ["dotnet", "test"]
84+
CMD ["make", "test"]
4985

5086
###############################################################################
5187
### In production stage
5288
## in the production phase, "good practices" such as
53-
## WORKSPACE and USER are maintained
89+
## WORKDIR and USER are maintained
5490
##
55-
FROM builder AS production
91+
FROM mcr.microsoft.com/dotnet/runtime:8.0.3-alpine3.19-amd64 AS production
5692

57-
ENV LOG_LEVEL=INFO
93+
ENV LOG_LEVEL=info
5894
ENV BRUTEFORCE=false
95+
ENV WORKDIR=/app
96+
WORKDIR ${WORKDIR}
5997

6098
RUN adduser -D worker
6199
RUN mkdir -p /app
62100
RUN chown worker:worker /app
63101

64-
WORKDIR /app
102+
RUN apk add --update --no-cache make
103+
COPY ./Makefile ${WORKDIR}/
104+
COPY --from=builder /app/algorithm-exercises-csharp/bin/Release/net8.0/algorithm-exercises-csharp.dll ${WORKDIR}/
105+
COPY --from=builder /app/algorithm-exercises-csharp/bin/Release/net8.0/algorithm-exercises-csharp.runtimeconfig.json ${WORKDIR}/
65106

66-
COPY ./.pylintrc ${WORKDIR}/
67-
COPY ./.coveragerc ${WORKDIR}/
68107
RUN ls -alh
69108

70109
USER worker
71-
CMD ["make", "test", "-e", "{DEBUG}"]
110+
CMD ["make", "run"]

LICENSE renamed to LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
# MIT License
22

33
Copyright (c) 2022 Gonzalo Diaz
44

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ format:
8787
build: env dependencies
8888
${PACKAGE_TOOL} build --verbosity ${VERBOSITY_LEVEL}
8989

90+
release: dependencies
91+
${PACKAGE_TOOL} publish --verbosity ${VERBOSITY_LEVEL}
92+
9093
test: build
9194
${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL} --collect:"Code Coverage"
9295

@@ -119,10 +122,12 @@ clean:
119122
compose/build: env
120123
docker-compose --profile lint build
121124
docker-compose --profile testing build
125+
docker-compose --profile production build
122126

123127
compose/rebuild: env
124128
docker-compose --profile lint build --no-cache
125129
docker-compose --profile testing build --no-cache
130+
docker-compose --profile production build --no-cache
126131

127132
compose/lint/markdown: compose/build
128133
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make lint/markdown
@@ -134,11 +139,17 @@ compose/test/styling: compose/build
134139
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make test/styling
135140

136141
compose/test/static: compose/build
137-
docker-compose --profile testing run --rm algorithm-exercises-csharp make test/static
142+
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make test/static
138143

139144
compose/lint: compose/lint/markdown compose/lint/yaml compose/test/styling compose/test/static
140145

146+
compose/test: compose/build
147+
docker-compose --profile testing run --rm algorithm-exercises-csharp-test make test
148+
141149
compose/run: compose/build
142-
docker-compose --profile testing run --rm algorithm-exercises-csharp make test
150+
docker-compose --profile production run --rm algorithm-exercises-csharp make run
143151

144152
all: lint coverage
153+
154+
run:
155+
ls -alh

algorithm-exercises-csharp/algorithm-exercises-csharp.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88

9+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
10+
911
<!-- Static Analysis -->
1012
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1113
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

compose.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
services:
3-
algorithm-exercises-csharp:
4-
image: algorithm-exercises-csharp:latest
3+
algorithm-exercises-csharp-test:
4+
image: algorithm-exercises-csharp:test
55
build:
66
context: .
77
target: testing
@@ -18,8 +18,8 @@ services:
1818
context: .
1919
target: lint
2020
# environment:
21-
#  LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug
22-
#  BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
21+
# LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug
22+
# BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
2323
volumes:
2424
- ./:/app
2525
profiles: ["lint"]
@@ -35,6 +35,19 @@ services:
3535
volumes:
3636
- ./:/app
3737
profiles: ["development"]
38+
39+
algorithm-exercises-csharp:
40+
image: algorithm-exercises-csharp:latest
41+
build:
42+
context: .
43+
target: production
44+
environment:
45+
LOG_LEVEL: ${LOG_LEVEL:-INFO}
46+
BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
47+
# volumes:
48+
# - ./:/app
49+
profiles: ["production"]
50+
3851
## REFERENCES:
3952
## (1) Passing Environment variable with fallback value:
4053
## https://stackoverflow.com/a/70772707/6366150

0 commit comments

Comments
 (0)