tangled
alpha
login
or
join now
kacaii.dev
/
senac-brigade-server
0
fork
atom
wip: currently rewriting the project as a full stack application
tangled.org/kacaii.dev/sigo
gleam
0
fork
atom
overview
issues
1
pulls
pipelines
:building_construction: prefer using docker containers
kacaii.dev
2 months ago
94fc850e
7911535a
+50
-11
3 changed files
expand all
collapse all
unified
split
Taskfile.yml
dockerfile
src
app
supervision_tree.gleam
+48
Taskfile.yml
···
1
1
+
version: "3"
2
2
+
3
3
+
vars:
4
4
+
USERNAME: kacaii
5
5
+
IMAGE_NAME: senac-brigade-server
6
6
+
TAG_NAME: latest
7
7
+
FULL_IMAGE_NAME: "{{.USERNAME}}/{{.IMAGE_NAME}}:{{.TAG_NAME}}"
8
8
+
PORT: 8000
9
9
+
10
10
+
tasks:
11
11
+
default:
12
12
+
desc: List available tasks
13
13
+
cmd: task --list-all
14
14
+
silent: true
15
15
+
16
16
+
docker:run:
17
17
+
desc: Run the container
18
18
+
cmd: >
19
19
+
docker run
20
20
+
-e DATABASE_URL=$DATABASE_URL
21
21
+
-e COOKIE_TOKEN=$COOKIE_TOKEN
22
22
+
-e ADMIN_TOKEN=$ADMIN_TOKEN
23
23
+
-p {{.PORT}}:{{.PORT}}
24
24
+
{{.IMAGE_NAME}}:{{.TAG_NAME}}
25
25
+
26
26
+
docker:shipment:
27
27
+
desc: Build, Tag and Push your app
28
28
+
cmds:
29
29
+
- task: docker:build-image
30
30
+
- task: docker:tag-image
31
31
+
- task: docker:push-image
32
32
+
33
33
+
# Docker Internal Tasks ------------------------------------------------------
34
34
+
35
35
+
docker:build-image:
36
36
+
internal: true
37
37
+
desc: Build Docker image
38
38
+
cmd: docker-buildx build --file dockerfile --tag {{.IMAGE_NAME}} .
39
39
+
40
40
+
docker:tag-image:
41
41
+
internal: true
42
42
+
desc: Tag container image
43
43
+
cmd: docker tag {{.IMAGE_NAME}}:{{.TAG_NAME}} {{.FULL_IMAGE_NAME}}
44
44
+
45
45
+
docker:push-image:
46
46
+
internal: true
47
47
+
desc: Push to container registry
48
48
+
cmd: docker push {{.FULL_IMAGE_NAME}}
+1
-5
dockerfile
···
14
14
15
15
# Final stage
16
16
FROM erlang:${ERLANG_VERSION}-alpine
17
17
-
ARG GIT_SHA
18
18
-
ARG BUILD_TIME
19
19
-
ENV GIT_SHA=${GIT_SHA}
20
20
-
ENV BUILD_TIME=${BUILD_TIME}
21
21
-
ENV DATABASE_URL=${DATABASE_URL}
22
17
23
18
RUN \
24
19
addgroup --system webapp && \
···
31
26
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD [ "/app/healthcheck.sh" ]
32
27
33
28
WORKDIR /app
29
29
+
34
30
ENTRYPOINT ["/app/entrypoint.sh"]
35
31
CMD ["run"]
+1
-6
src/app/supervision_tree.gleam
···
33
33
}
34
34
}
35
35
36
36
-
let bind_to = case ctx.env {
37
37
-
context.Production -> "0.0.0.0"
38
38
-
context.Dev -> "localhost"
39
39
-
}
40
40
-
41
36
// Adding Mist to the supervision tree
42
37
let mist_pool_child =
43
38
webserver_handler
44
39
|> mist.new
45
45
-
|> mist.bind(bind_to)
40
40
+
|> mist.bind("0.0.0.0")
46
41
|> mist.port(8000)
47
42
48
43
// Starting supervision