Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/alpine containers #625

Merged
merged 12 commits into from
Sep 5, 2022
7 changes: 5 additions & 2 deletions .github/workflows/apidocs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: API docs

on: [push]
Expand All @@ -9,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.17]
go-version: [1.19]
steps:

- name: Set up Go ${{ matrix.go-version }}
Expand All @@ -23,7 +24,9 @@ jobs:

- name: Get swag
run: |
go get -u github.com/swaggo/swag/cmd/swag
go get github.com/swaggo/swag/[email protected]
go get github.com/swaggo/swag/cmd/[email protected]
go install github.com/swaggo/swag/cmd/[email protected]
working-directory: backend

- name: Check that docs can be created
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Tests

on: [push]
Expand All @@ -9,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.17]
go-version: [1.19]
steps:

- name: Set up Go ${{ matrix.go-version }}
Expand Down
20 changes: 10 additions & 10 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM golang:1.17.11-stretch
FROM golang:1.19-alpine3.16

ENV XDG_CACHE_HOME='/tmp/.cache'

WORKDIR /app

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
SHELL ["/bin/ash", "-o", "pipefail", "-c"]

RUN apt-get update; \
apt-get upgrade -y; \
apt-get install --no-install-recommends -y git='1:2.*'; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
curl --fail --location \
'https://raw.githubusercontent.com/cosmtrek/air/v1.29.0/install.sh' | \
sh -e -s v1.29.0 && cp -v ./bin/air /bin/air
RUN apk --no-cache add \
'curl=~7.83.1' \
'gcc=~11.2.1' \
'musl-dev=~1.2.3'; \
rm -rf /var/cache/apk/*; \
curl --silent --fail --location \
'https://raw.githubusercontent.com/cosmtrek/air/v1.40.4/install.sh' | \
sh -e -s v1.40.4 && cp -v ./bin/air /bin/air

CMD ["air"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
build:
context: ./
dockerfile: ./node/Dockerfile
command: bash -c "rm -rf /home/node/app/node_modules/* && npm run start"
command: sh -c 'rm -rf /home/node/app/node_modules/* && npm run start'
volumes:
- ./frontend:/home/node/app/
- exclude:/home/node/app/node_modules
Expand Down
2 changes: 1 addition & 1 deletion node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.8.0-slim as build
FROM node:18.8.0-alpine as build

USER node
RUN mkdir /home/node/app
Expand Down
9 changes: 5 additions & 4 deletions production/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM golang:1.18.5-alpine3.15 as builder
FROM golang:1.19-alpine3.16 as builder

ENV GOPATH=$PWD

WORKDIR /go

COPY ./ .

RUN apk --update add gcc=10.3.1_git20211027-r0 \
musl-dev=1.2.2-r7 --no-cache && \
RUN apk --no-cache add \
'gcc=~11.2.1' \
'musl-dev=~1.2.3'; \
rm -rf /var/cache/apk/*

RUN go build -o ./urdr ./cmd && \
echo "urdr:x:1001:1001:urdr:/:/sbin/nologin" > passwd

FROM alpine:3.16.2
FROM alpine:3.16

WORKDIR /app

Expand Down
6 changes: 3 additions & 3 deletions production/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:18.8.0-slim as build
FROM node:18.8.0-alpine3.16 as build

USER node
RUN mkdir /home/node/app
WORKDIR /home/node
COPY --chown=node:node ./package.json ./package-lock.json ./
RUN npm ci

FROM node:18.8.0-slim as bundler
FROM node:18.8.0-alpine3.16 as bundler

ARG PUBLIC_API_URL
ENV PUBLIC_API_URL=${PUBLIC_API_URL}
Expand All @@ -21,7 +21,7 @@ COPY --chown=node:node /. /home/node/app/
COPY --from=build --chown=node:node /home/node/node_modules/ /home/node/app/node_modules/
RUN npm run build

FROM nginx:1.23.1
FROM nginx:1.23.1-alpine

RUN mkdir -p /app/dist
COPY --from=bundler --chown=www-data:www-data /home/node/app/public/ /app/dist